Skip to content

Redis

Redis is an open source key-value cache and non-SQL database released under the BSD license.

Configuration file

The configuration file can be downloaded using the command:
fetch https://raw.githubusercontent.com/antirez/redis/6.2/redis.conf

Unixsocket

The recommended way to host a Redis server on Serv00.com is unixsocket. This is a special file through which the Redis server and the application communicate with each other.

To configure the server to be accessible via unixsocket, set the following variables in the redis.conf file:

  • port to 0
  • unixsocket to /usr/home/LOGIN/domains/DOMAIN/redis.sock

Where:

  • LOGIN is the name of the hosting account
  • DOMAIN is the domain of the site that Redis is running on.

Password

Warning

If no password is set, each Serv00.com hosting user will have access to the cache system and its contents.

To define the password for the Redis server, enter it after the phrase requirepass in the redis.conf configuration file.

Port

Warning

After setting the service to a given port, unless the listening configuration file is limited to 127.0.0.1, the cache system will be available remotely - so it is absolutely necessary to set the access password!

To configure the server to be accessible via a port, you must first reserve a TCP port. Then you need to set the port variable in the redis.conf file to reserved port number.

Restrict access

By default, Redis listens on all network interfaces. To restrict listening to localhost, set the bind variable in the redis.conf file to 127.0.0.1.

Persistence

Persistence, i.e. database resilience in the case of Redis, has 2 mechanisms: RDB and AOF. Each of them is configurable, which is described below. Both can be turned on or both off. By default, all the files listed below are saved to the location from which the Redis server was started.

RDB

RDB (Redis DataBase) consists in dumping the database from RAM periodically and after a certain number of changes to the database. The default configuration saves the database to a dump.rdb file which:

  • every 900 seconds (15 minutes), if there was at least one change (in the configuration it is the line: save 900 1),
  • every 300 seconds (5 minutes) if there were at least 10 changes (save 300 10),
  • every 60 seconds if there have been at least 10000 changes (save 60 10000).

The name of the file where the database is dumped is defined by the dbfilename variable.

To disable RDB remove the save lines from the configuration.

AOF

AOF (Append Only File) is about writing write commands (those that change data). The default configuration does not use the AOF mechanism. A file created in this way can be many times larger than the size of the database. The name of the AOF file is defined by the appendfilename variable.

It is possible to reduce file size by rebuilding the AOF file without breaking Redis.

To enable AOF change appendonly to yes.

Startup

To start the Redis server, use the command:

screen redis-server redis.conf

PHP

On Serv00.com servers, Redis is also available from PHP using the appropriate module.