Free Support via:  +31 (0)20 796 9999

How to implement REDIS in Magento 1.x?

HINT: If you have a CMS hosting account (WordPress Performance, Magento Business, Joomla Express, Drupal Express, etc.), Combell will automatically choose the best caching method for you and configure it. You do not need to go through this procedure.

To implement Redis in Magento 1.x, follow the steps below:

Activate Redis

  1. First make sure you Activate Redis caching from your control panel

Adjust Magento 1.X for use REDIS

REDIS support is already built in Magento Community Edition 1.x since version 1.8. You do not need to install additional modules. We just need to change a few small things in the config files.

Switch on REDIS support

Switch on Redis support

In SSH navigate to the directory where Magento is installed. Then open the following file in vi:

    vi app/etc/modules/Cm_RedisSession.xml

In this file you will find the following content:

    <config>
      <modules>
        <Cm_RedisSession>
          <active>false</active>
          <codePool>community</codePool>
        </Cm_RedisSession>
      </modules>
    </config>

Change this value from “false” to “true” so as to achieve the following:

    <config>
      <modules>
        <Cm_RedisSession>
          <active>true</active>
          <codePool>community</codePool>
        </Cm_RedisSession>
      </modules>
    </config>

Now save that.

Edit app/etc/local.xml

Assuming you’re still in the root of Magento installation, you now enter the following command:

    vi app/etc/local.xml

You will fill this file with the following code:

    <cache>
              <backend>Cm_Cache_Backend_Redis</backend>
              <backend_options>
                <server>250.250.250.1</server>
                <port>10000</port>
                <persistent></persistent>
                <database>0</database>
                <password>Jh7whJHUijxnn9n823nzHjh9</password>
                <force_standalone>0</force_standalone>
                <connect_retries>1</connect_retries>
                <read_timeout>10</read_timeout>
                <automatic_cleaning_factor>0</automatic_cleaning_factor>
                <compress_data>1</compress_data>
                <compress_tags>1</compress_tags>
                <compress_threshold>20480</compress_threshold>
                <compression_lib>gzip</compression_lib>
                <use_lua>0</use_lua>
              </backend_options>
    </cache>

This block of code has to be added after the </ crypt> and before tags in this file. In the example, of course, you adjust the value at , , to the values of the customer REDIS instance.

After the adjustments local.xml file should look as follows:

    <config>
        <global>
            <install>
                <date><![CDATA[Wed, 18 Feb 2015 10:34:16 +0000]]></date>
            </install>
            <crypt>
                <key><![CDATA[54140ba78d6q8ad6ad60ead96]]></key>
            </crypt>
         <cache>
              <backend>Cm_Cache_Backend_Redis</backend>
              <backend_options>
                <server>250.250.250.2</server>
                <port>10000</port>
                <persistent></persistent>
                <database>0</database>
                <password>Jh7whJHUijxnn9n823nzHjh9</password>
                <force_standalone>0</force_standalone>
                <connect_retries>1</connect_retries>
                <read_timeout>10</read_timeout>
                <automatic_cleaning_factor>0</automatic_cleaning_factor>
                <compress_data>1</compress_data>
                <compress_tags>1</compress_tags>
                <compress_threshold>20480</compress_threshold>
                <compression_lib>gzip</compression_lib>
                <use_lua>0</use_lua>
              </backend_options>
            </cache>
    <disable_local_modules>false</disable_local_modules>
            <resources>
                <db>
                    <table_prefix><![CDATA[]]></table_prefix>
                </db>
                <default_setup>
                    <connection>
                        <host><![CDATA[mysql022.webhosting.be]]></host>
                        <username><![CDATA[ID140195_magento]]></username>
                        <password><![CDATA[LQPBIUYtbiBTbVPifTG]]></password>
                        <dbname><![CDATA[ID140195_magento]]></dbname>
                        <initStatements><![CDATA[SET NAMES utf8]]></initStatements>
                        <model><![CDATA[mysql4]]></model>
                        <type><![CDATA[pdo_mysql]]></type>
                        <pdoType><![CDATA[]]></pdoType>
                        <active>1</active>
                    </connection>
                </default_setup>
            </resources>
            <session_save><![CDATA[files]]></session_save>
        </global>
        <admin>
            <routers>
                <adminhtml>
                    <args>
                        <frontName><![CDATA[admin]]></frontName>
                    </args>
                </adminhtml>
            </routers>
        </admin>
    </config>

Clear the Magento cache

From the root directory of your Magento installation execute the command:

    rm -rf var / cache

Login in the backend of Magento. Go to “System” => “Cache Management” and click on “Flush Magento Cache”.

Checking Redis

Then check if the Redis Cache is being correctly filled. This is done as follows via the Redis-CLI:

Execute this command:

redis-cli -h redisipadress -p redisportnumber

Example:

redis-cli -h 250.250.250.1 -p 10000

This is what will appear

250.250.250.1:10000>

Now enter the word “AUTH” followed by the password of the Redis instance and press enter. This looks like this:

250.250.250.1:10000> AUTH ***************

You should now get an “OK” back. Respond with executing this command: “keys *” like so:

250.250.250.1:10000> keys *

If Redis is configured properly, you see an output similar to the following:

1) "zc:k:f01_B95179D8427D4CD3A6E015530E9E"
2) "zc:ti:f01_BLOCK_SLIDE2"
3) "zc:k:f01_Zend_LocaleC_nl_NL_country_MR"
4) "zc:ti:f01_BLOCK_CATEGORY_ABOVE_EMPTY_COLLECTION"
5) "zc:k:f01_A9B2A0BB16F05FAA2371C0A5FB79E81C"
6) "zc:k:f01_CMS_BLOCK_BLOCK_LEFT_TOP_1_1"
7) "zc:k:f01_Zend_LocaleC_sv_SE_language_sv"
Updated on 24 September 2020

Was this article helpful?

Related Articles