Redis for cache and sessions
Oct 26, 2026
By default WHBMP keeps its cache and its sign-in sessions in the database, which works everywhere. On a busy site, or a server where the database is the slow part, Redis is faster because it keeps them in memory and the database does less work. It is optional: nothing breaks if you never switch.
What you need
- Redis running on the server, reachable from the site. On a VPS you install it yourself (
apt install redis-server). On shared hosting, ask the host whether Redis is offered. - The PHP Redis extension (phpredis) for the PHP version the site uses. Check with
php -m | grep -i redis.
If either is missing, stay on the database. Pointing the site at a Redis that is not there makes every page fail until you change it back.
Turn it on
Edit the .env file in the site's folder and change these lines:
CACHE_STORE=redis
SESSION_DRIVER=redis
REDIS_CLIENT=phpredis
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_PASSWORD=null
Then clear the cached settings once:
php artisan config:clear
php artisan cache:clear
Everyone who is signed in has to sign in again once, because their sessions were in the database.
If your Redis has a password, put it in REDIS_PASSWORD. Keep Redis listening on 127.0.0.1 only, never on a public address.
Two sites on one server
Two WHBMP sites on the same Redis (for example a main site and a demo) must not share keys. Give each site its own database numbers and prefixes, or one site will read the other's cache and sessions:
REDIS_DB=2
REDIS_CACHE_DB=3
REDIS_PREFIX=demo-whbmp-database-
CACHE_PREFIX=demo-whbmp-cache-
Use different numbers and prefixes on every site. The numbers matter most: clearing the cache empties a whole Redis database. Redis has 16 databases, numbered 0 to 15.
The queue
QUEUE_CONNECTION can also be redis, but only if a queue worker is running (php artisan queue:work). A standard install has no worker, so leave the queue on database. Jobs that were waiting in the database when you switch are not moved.
Go back
Set CACHE_STORE=database and SESSION_DRIVER=database again, then run php artisan config:clear. Nothing is lost: settings, clients and invoices live in the database, not in the cache.
Good to know
- Running
php artisan cache:clearempties the whole Redis database the cache uses (REDIS_CACHE_DB). Give every site its own number, or clearing one site empties the other's cache too. - If Redis restarts, the cache refills by itself. Sessions kept in Redis are lost on a restart unless Redis has persistence switched on (it does by default on most installs), so people may need to sign in again.
- Memcached works for the cache and sessions too (
CACHE_STORE=memcached), but not for the queue. Redis is the better choice. - Signing someone out: with sessions in the database, resetting a password or removing a staff member also ends that person's other open sessions at once. With sessions in Redis that step does not happen, so their other browsers stay signed in until the session expires (120 minutes without activity by default). A restricted staff account is still stopped on its next click, and mobile app access is still ended straight away. If instant sign-out matters more to you than speed, keep
SESSION_DRIVER=databaseand use Redis for the cache only.