Tips Official Redis Cache

Compatible XF 2.x versions
  1. 2.x
To setup XenForos build in Redis you do not need any addon.

In Ubuntu 24.04

1. Install Redis​

Bash:
Bash:
#apt install php8.3-redis

2. In src/config.php​

PHP:
$config['cache']['enabled'] = true;
$config['cache']['sessions'] = true;
$config['cache']['provider'] = 'Redis';
$config['cache']['config']['host'] = '127.0.0.1';
This is all you need and works out of the box. You see, using Redis as a cache is very easy.

Longer version for other Linux distributions

1. Install Redis
If you install the Redis php connector, the Redis-server itself will be installed automatically.
Bash:
#apt search redis | grep php
(...)
php8.2-redis
php8.3-redis
Here php8.3-redis matches my php version so I install this connector (as well as the Redis-server) with one line
Bash:
#apt install php8.3-redis
Then start the Redis-server (in Ubuntu you do not need to do that, it does that automatically).
Bash:
#systemctl enable redis-server
#systemctl start redis-server
#systemctl status redis-server
In Redhat you would use
Bash:
#dnf search redis | grep php
(...)
php8.2-redis
php8.3-redis
#dnf install php8.3-redis
In SUSE you use #zypper search redis | grep php
PHP:
//$config['cache']['provider'] = 'Filesystem';

3. In src/config.php

PHP:
$config['cache']['enabled'] = true;
$config['cache']['sessions'] = true;
$config['cache']['provider'] = 'Redis';
$config['cache']['config']['host'] = '127.0.0.1';

Why use Redis instead of the Filesystem?

Both work great with XenForo. The Filesystem works great as also a cache, but Redis is meant to be one.

Disadvantages for the Filesystem

  • you have to create a Filesystem directory (not needed for Redis)
  • Filesystem directory has to be inaccessible for the Web
  • Filesystem directory must have permissions for PHP to still write on it even when away from the public Web
  • XenForo must check whether the written files in the Filesystem are too old or not (in Redis you can set a time frame in which the data is valid, then the data will be removed automatically)
  • in the Filesystem the files can be actually be cached in RAM and therefore it can be very fast (if you have lots of RAM) but you are not sure about that
To setup the Filesystem you set a "directory" in config.php (different for each installation), for Redis you set a "host" (which is usually always the same).
RedisFilesystem
host=127.0.0.1directory=/…………..
Thats all the difference for a minimal configuration between these two.
Related resources
Your Linux does not provide you with a Redis php connector ? But you have Redis-server installed and running? This addon
is for you:
While XenForo 2 has a redis connector, it requires phpredis. This add-on does not.
 

Similar threads

October 2024

Total amount
$160.50
Goal
$400.00
Donation ends:

Staff online

Forum statistics

Threads
10,651
Messages
28,709
Members
48,020
Latest member
lazersate
Top