How to use Redis Cache in Opencart for better performance

As you already know Redis is an open source (BSD - Berkeley Software Distribution licensed), in-memory data structure store, used as a database, cache and message broker. This cache technology takes place in many app performance improvements by supporting data structures such as: lists, strings, hashes, sorted sets with range queries, sets, hyperloglogs, hyperloglogs, bitmaps and geospatial indexes with radius queries. It has Lua scripting, built-in replication, transactions and different levels of on-disk persistence, LRU eviction, and even built-in replication. Redis also provides automatic partitioning with Redis Cluster and high availability via Redis.

If you have a store build-on Opencart, Redis can be really helpful solution to achieve better performance. "But how?" you will ask and we are here to give you the answer.

You can use Redis with Opencart right away with a few click and 2-3 lines of code. Thanks to the integration within our DirectAdmin control panel you will get about 5 times faster Opencart store without being a tech guy. The only thing you have to do in your code is to:

1. Go to /system/config/default.php and edit it by change the value of $_[‘cache_type’].

$_['cache_engine'] = 'redis';

2. Or you can enable it from your control panel.

Redis Control Panel Icon

and than:

Redis Settings

3. Now is the time to define several constants. You should change both config files: /config.php and /admin/config.php or you can do these changes in either /system/startup.php or /system/framework.php (before cache object in this case). You also should define following constants:

define('CACHE_HOSTNAME', '/home/your-user/.redis/redis_sock');
define('CACHE_PORT', '0');
define('CACHE_PREFIX', 'redis_');

your-user stands for your the user of your hosting

Everything should be working properly now. Now your Opencart uses of Redis and the speed is forced to higher levels.

Was this article helpful?

mood_bad Dislike 36
mood Like 10
visibility Views: 2583