Back to Top

Using Redis Cache In Opencart

Updated 24 August 2017

Nowadays, caching has become a hot topic of discussion as everyone wants to maintain their website’s speed even on handling millions of users at a time. Opencart is using caching since its initial days like used file cache in version 1.5, then added APC (Alternative PHP Cache) and Memcache in version 2 and now in version 3 added Redis library.

Redis Introduction

Redis has its own advantages. According to its website, Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs and geospatial indexes with radius queries. Redis has built-in replication, Lua scripting, LRU eviction, transactions and different levels of on-disk persistence, and provides high availability via Redis Sentinel and automatic partitioning with Redis Cluster.

Redis is an in-memory data structure server. You can add any values to Redis cache like integers, string etc.

How to use Redis with Opencart?

Searching for an experienced
Opencart Company ?
Find out More

In order to use Redis with Opencart, you have to first install Redis to your server. Here is the Download Link.

Then you have to install phpredis to your server.

You can check Redis in phpinfo().

Now, you have to make some changes to your opencart system. You have to edit system->config->default.php and change the value of $_[‘cache_type’].

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

You also need to define a few constants. Either you can make changes in both config.php and admin->config.php or you can perform change either in system->startup.php or system->framework.php (before cache object in this case). You have to define following constants.

define('CACHE_HOSTNAME', '');
define('CACHE_PORT', '6379');
define('CACHE_PREFIX', 'redis_');

Now, you are complete with the changes in Opencart and you can make use of Redis on your website.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


  • Abhishek Jain
    • Neelesh Singh (Moderator)
  • Martin Koch
    • Govinda (Moderator)
  • Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home