Menu Close
    Start a Project Request quote Reading list Switch to dark mode
    opencart-hyperlocal-marketplace-guide

    Using Redis Cache In Opencart

    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?

    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’].


    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.


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

    . . .

    Comments (2)

    Add Your Comment

  • Martin Koch
    i did try to install redis on my website it’s active on the server changed the default.php file and put the code into both config files but what i get is a white screen
    • Govinda
      Hello Martin,

      The socket connection to the host may not be opened on your server so here you may get the Fatal error: Uncaught RedisException: Connection refused in /home/users/demo/www/html/system/library/cache/redis.php:12.

      To show this error, add this code in the index.php file-

      ini_set(‘display_errors’, TRUE);

      To check the socket connection –
      if (@fsockopen(CACHE_HOSTNAME, CACHE_PORT, $errno, $errstr, 30)) {
      echo “Connected”;
      } else {
      echo “Not Connected”;
      }

      Still, you have any query, you can ask in the comment.

  • Back to Top
    css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again
    Close