> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.hodi.host/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# How do I use Redis on my site?

> Redis is an in-memory cache. Instead of rebuilding every page by querying the database, your site stores the results in RAM and then reads them back in a fraction
> of a millisecond. On a reasonably busy WordPress, Laravel, Magento or PrestaShop site, this is often the most visible performance gain for the least effort.
>
> Your Redis instance is private: it is reserved for you, it runs under your own user account, and no other customer on the server can access it.

### How do I enable Redis?

In cPanel, under *Databases*, open **Redis**, choose the profile closest to your site (WordPress, Laravel / Symfony, Magento / PrestaShop, or PHP sessions)
then click **Enable Redis**. The instance starts immediately and the page displays your connection details.

All the settings remain editable afterwards: the profile only pre-fills the memory limit, the eviction policy and the number of databases.

### Which connection details should I use?

The cPanel Redis page displays everything your application needs:

* **the socket file**, in the form `/home/youraccount/.redis/redis.sock`;
* **the password** (*Show* button to read it, *Copy* to grab it);
* **the database number** to use;
* depending on your plan, a **host and port** (see below).

### Socket or port: what's the difference?

The **socket** is a local communication file. This is the recommended method: it is faster than the network, and the data never leaves the server. All the common clients support it, in particular the PHP `phpredis` extension, LiteSpeed Cache and Laravel.

The **port** (on `127.0.0.1`) exists for the rare applications that cannot use a socket. It is included from the **SITE PRO** plan upwards. On the other plans, use the socket: you lose nothing in functionality, quite the contrary.

### How do I configure WordPress?

The simplest option is the **LiteSpeed Cache** plugin, under *Cache > Object*:

* method: Redis;
* host: paste the path to the socket file;
* port: `0`;
* password: the one shown in cPanel;
* database: your database number.

With the **Redis Object Cache** plugin, add these lines to `wp-config.php` instead, before the `/* That's all, stop editing! */` line:

```php
define( 'WP_REDIS_SCHEME', 'unix' );
define( 'WP_REDIS_PATH', '/home/youraccount/.redis/redis.sock' );
define( 'WP_REDIS_PASSWORD', 'your_password' );
define( 'WP_REDIS_DATABASE', 0 );
```

Then enable the object cache from the plugin. The cPanel Redis page displays this block pre-filled with your values: you can copy it directly.

### How do I configure Laravel or Symfony?

In your application's `.env` file:

```
REDIS_CLIENT=phpredis
REDIS_HOST=/home/youraccount/.redis/redis.sock
REDIS_PORT=0
REDIS_PASSWORD=your_password
REDIS_DB=0
CACHE_DRIVER=redis
SESSION_DRIVER=redis
```

Remember to clear your application's configuration cache afterwards
(`php artisan config:clear`).

### Can I access it from the command line?

Yes, from an SSH connection or the cPanel Terminal. The page displays the exact command, password included:

```
redis-cli -s /home/youraccount/.redis/redis.sock -a 'your_password'
```

### Can I connect to it from outside the server?

No, and that is deliberate. Your instance only listens on the server itself. A cache reachable from the Internet is a risky way in.