Magento 1.9 – Redis Cm_Cache_Backend_Redis Not Adding Keys

magento-1.9redis

I'm trying to use CM_Cache_Backend_Redis to cache database calls and sessions. I have the following configuration inside near the bottom of my app/etc/local.xml file:

<cache>
    <backend>Cm_Cache_Backend_Redis</backend>
    <backend_options>
            <server>172.31.39.160</server>
            <port>6379</port>
            <database>0</database>
            <password></password>
            <force_standalone>1</force_standalone>
            <connect_retries>1</connect_retries>
            <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>
            <persistent>1</persistent>
            <log_level>7</log_level>
    </backend_options>
</cache>

<full_page_cache>
    <backend>Cm_Cache_Backend_Redis</backend>
    <backend_options>
            <server>172.31.39.160</server>
            <port>6379</port>
            <database>1</database>
            <password></password>
            <force_standalone>0</force_standalone>
            <connect_retries>1</connect_retries>
            <automatic_cleaning_factor>0</automatic_cleaning_factor>
            <compress_data>0</compress_data>
            <compress_tags>1</compress_tags>
            <compress_threshold>20480</compress_threshold>
            <compression_lib>gzip</compression_lib>
            <lifetimelimit>43200</lifetimelimit>
            <persistent>2</persistent>
            <log_level>7</log_level>
    </backend_options>
</full_page_cache>

<session_save>db</session_save>
<redis_session>
    <host>172.31.39.160</host>
    <port>6379</port>
    <password></password>
    <timeout>2.5</timeout>
    <persistent></persistent>
    <db>0</db>
    <compression_threshold>2048</compression_threshold>
    <compression_lib>gzip</compression_lib>
    <log_level>7</log_level>
    <max_concurrency>6</max_concurrency>
    <break_after_frontend>5</break_after_frontend>
    <break_after_adminhtml>30</break_after_adminhtml>
    <bot_lifetime>7200</bot_lifetime>
</redis_session>

I've cleared my cache and session information, rebuilt all my indexes and restarted Apache and it Magento isn't even attempting to connect to the Redis server.

The Redis server is a separate server from the Web Server (they're both in an Amazon VPC). I've confirmed that I can use redis-cli from the web server and manually access/update the redis database. There is nothing in Magento's var/log/system.log or Apache's error log about even attempting to connect to the redis database.

If I use tcpdump I can see that there is absolutely no traffic on port 6379 during various page loads.

It would help if I could get an error message at least, but this is failing silently.

Best Answer

Ok since iam currently developing a Magento Clearcache Module, that handles Memcached, Redis and Apc i ran across your problem and could maybe help you out:

Lets start with:

<force_standalone>0</force_standalone>

0 is for standalone PHP

but in most cases you will use

1 for phpredis

which means with 0 you wont be able to connect to redis from php since the wrong adapter is selected.

From your local.xml i assume you'r using Cm_RedisSession as well ?

if so, what will the following command bring up to you:

connect the redis-cli to your redis server and:

info keyspace

if you now get:

 "#keyspace"
  • you wont get any data to redis at all

  • if you get something like:

db3:keys=405,expires=23,avg_ttl=7197349

that means, that your sessions are stored within redis but the backend isn't.

If so feel free to drop a short message here and we can go on from there.