Redis¶
The Redis service is used to install and run Redis. The installation is configured as a cache, no data is stored persistently.
You can fully configure Redis through the Custom JSON Server Level Configuration.
Enable¶
To install Redis, set redis::ensure
to present.
Memory Ratio¶
By default, a memory_ratio
of 4 is used, which means Redis
will take up to 50% of the servers total memory.
maxmemory_policy¶
maxmemory_policy
is configured to noeviction
by default.
Read more about maxmemory at Redis.
Full example¶
{
"redis::ensure": "present",
"redis::memory_ratio": "4",
"redis::maxmemory_policy": "noeviction"
}
Usage¶
By default, Redis is listen on localhost, port 6379 (127.0.0.1:6379
).
PHP¶
Depending on your applications requirements, you might need the phpredis extension to use Redis from PHP. The extension is precompiled and installed, but not loaded by default.
To load phpredis in your environment, specify the extenion in ~/cnf/php.ini
:
extension = redis.so
Debugging¶
For debugging purposes, use redis-cli to connect to the Redis server:
$ redis-cli set key1 test
OK
$ redis-cli --scan
key1
$ redis-cli get key1
"test"
Tip
For details, see the redis-cli documentation.