Skip to content

Commit afdc760

Browse files
authored
Merge pull request #469 from ByteInternet/update-redis-woocommerce
improved wording and add cache ttl explanation to woocommerce redis docs
2 parents cd18c1d + 3783228 commit afdc760

1 file changed

Lines changed: 30 additions & 4 deletions

File tree

docs/ecommerce-applications/woocommerce/how-to-use-redis-with-woocommerce-and-wordpress-on-hypernode.md

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,44 @@ myst:
1111

1212
Remote Dictionary Server (Redis) is an in-memory, persistent, key-value database known as a data structure server. Unlike similar servers, Redis can store and manipulate high-level data types such as lists, maps, sets, and sorted sets.
1313

14-
By storing important data in its memory, Redis ensures fast data retrieval, significantly boosting performance and reducing response times.
14+
Because Redis stores data in memory, it can return frequently requested data very quickly. This can improve the performance of WordPress and WooCommerce by reducing database load and speeding up response times.
1515

1616
## Which Plugins Can We Use for Redis in WordPress/WooCommerce?
1717

1818
There are several plugins available for Redis. The two most commonly used are [Redis Object Cache](https://wordpress.org/plugins/redis-cache/) and [W3 Total Cache](https://wordpress.org/plugins/w3-total-cache/).
1919

2020
Due to the complexity of the cache module in "W3 Total Cache" and the possibility that you may already be using other cache plugins, we recommend the "Redis Object Cache" plugin.
2121

22+
## How to set a TTL on Redis keys
23+
24+
BBy default, most Redis plugins for WordPress do not set a TTL (time to live) on keys stored in Redis. This means cached keys may remain in memory indefinitely, which can eventually fill up Redis memory and lead to performance issues or downtime.
25+
26+
To set a TTL for all keys stored in Redis, add the following lines to your wp-config.php file:
27+
28+
```console
29+
define('WP_REDIS_PREFIX', 'example');
30+
define('WP_REDIS_MAXTTL', '900');
31+
define('WP_REDIS_SELECTIVE_FLUSH', true);
32+
```
33+
34+
```{important}
35+
Be sure to change the example prefix to a unique name for your application so Redis keys do not get mixed up when Redis is used by multiple applications on the same Hypernode.
36+
```
37+
38+
### Explanation of the wp-config.php options
39+
40+
- **WP_REDIS_PREFIX** adds a clear prefix to your Redis keys. This helps prevent key collisions, especially when multiple applications use Redis.
41+
- **WP_REDIS_MAXTTL** sets a maximum lifetime for cached items, in this example 900 seconds.
42+
- **WP_REDIS_SELECTIVE_FLUSH**\* ensures that only keys related to this WordPress installation are flushed, instead of clearing the entire Redis database.
43+
2244
## How to Install Redis Object Cache
2345

24-
Redis is already active on the server on port `6379`.
46+
Redis is already available on Hypernode and listens on port 6379.
47+
48+
Install the Redis Object Cache plugin through the WordPress Dashboard or with Composer. For general plugin installation steps, see the standard WordPress plugin installation documentation.
49+
50+
After installing and activating the plugin, go to Settings -> Redis or Network Admin -> Settings -> Redis on Multisite networks
2551

26-
Next, install the Redis Object Cache plugin via the WordPress Dashboard or using Composer. For detailed installation instructions, please refer to the standard installation procedure for WordPress plugins.
52+
Enable object caching and verify that the plugin connects to Redis automatically.
2753

28-
After installing and activating the plugin, navigate to `WordPress` -> `Settings` -> `Redis` or `Network Admin` -> `Settings` -> `Redis on Multisite networks`. Enable the cache and check if the plugin can connect automatically.
54+
If the plugin does not connect automatically, check whether Redis is reachable on 127.0.0.1:6379 and confirm that your WordPress configuration does not override the default connection settings.

0 commit comments

Comments
 (0)