Redis

The Redis service is used to install and run Redis. Redis is configured as a cache, therefore no data is stored persistently.

Redis is fully configured through the Custom JSON Server Level Configuration.

Enable

To install Redis, set redis::ensure to present.

Memory Ratio

By default, a memory_ratio of 2 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": "2",
  "redis::maxmemory_policy": "noeviction"
}

Usage

By default, Redis is bound to localhost on its default port 6379 (127.0.0.1:6379).

Tip

most applications will connect automatically with this default settings

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

Tip

For details, see custom PHP configuration.

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