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 1/4 of the servers total memory.

maxmemory_policy

maxmemory_policy is configured to noeviction by default. Read more about maxmemory at Redis.

protected

protected is configured to true by default.

If protected is configured to false, password must be set, if not, redis will not start.

Read more about protected-mode at Redis.

password

password is not set by default.

Your password must be at least 16 characters long, contain lower and uppercase letters, numbers and symbols.

Read more about ‘requirepass’ at Redis.

Full example

{
  "redis::ensure": "present",
  "redis::memory_ratio": "4",
  "redis::maxmemory_policy": "noeviction",
  "redis::protected": false,
  "redis::password": "sbVGHJKVHvgh78g1$?"
}

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.