Skip to main content
Redis gives your apps a fast key-value store for caching, sessions, rate limits and queues.

How Redis works on Servbase

  • A Redis database is a key prefix. A database named user0000_cache owns every key that starts with user0000_cache:.
  • A Redis user signs in with a username and password and can use only the keys of its own databases.
  • Redis is reachable only from your apps at 127.0.0.1:6390. It is not exposed to the internet.
  • Redis runs separately from the Servbase platform, and every customer is isolated from every other customer.
Redis memory is shared on each server. When it is full, the least recently used keys are removed. Use Redis for data you can rebuild (caches, sessions, queues), and keep the only copy of important data in MySQL or PostgreSQL.

Create a Redis database

1

Create a Redis user

Open Databases, select Create Database User, choose Redis, then enter a username and password.
2

Create the database

Select Create Database, choose the Redis user, and enter a name such as cache. The final name, for example user0000_cache, is the key prefix.
3

Add the variables to your app

Open your app, go to Settings, then Variables, and add:

Use it in your code

Every key must start with your prefix. The examples set the prefix once so the rest of your code does not need to.

Laravel

Set these in your app’s variables, then use the redis cache, session or queue driver:

Example: cache an API response (Express)

Commands that are not available

To keep customers isolated, commands that could see or change data outside your prefix, or affect the whole server, are disabled. These include KEYS, SCAN, RANDOMKEY, DBSIZE, INFO, SELECT, FLUSHDB, FLUSHALL, CONFIG, MONITOR, SORT, PUBSUB and FUNCTION.
  • To remove a group of keys, keep their names in a set, or give them an expiry time.
  • Laravel’s php artisan cache:clear uses FLUSHDB and is not available. Use cache tags or expiry times instead.
  • Pub/Sub channel names must also start with your prefix.
  • Libraries that call INFO while connecting may need that check turned off (for example enableReadyCheck: false in ioredis).

Change the password or delete

  • Change password: in Database Users, select the key icon. Apps using the old password are disconnected, so update REDIS_PASSWORD in your app variables.
  • Delete a database: removes every key with that prefix.
  • Delete the user: removes the user and all keys of its databases.