colinmollenhour / Cm_Cache_Backend_Redis

A Zend_Cache backend for Redis with full support for tags (works great with Magento)
Other
387 stars 143 forks source link

unable to connect via unix socket #61

Closed zafarella closed 10 years ago

zafarella commented 10 years ago

snip of 'app/etc/local.xml'

<cache>
  <backend>Cm_Cache_Backend_Redis</backend>
  <backend_options>
    <server><![CDATA[/tmp/redis6380.sock]]></server> <!-- or absolute path to unix socket -->
    <!-- <port>6380</port> -->
    <persistent></persistent> <!-- Specify unique string to enable persistent connections. E.g.: sess-db0; bugs with phpredis and php-fpm are known: https://github.com/nicolasff/phpredis/issues/70 -->
    <database>2</database> <!-- Redis database number; protection against accidental data loss is improved by not sharing databases -->
    <password></password> <!-- Specify if your Redis server requires authentication -->
    <force_standalone>1</force_standalone>  <!-- 0 for phpredis, 1 for standalone PHP -->
    <connect_retries>1</connect_retries>    <!-- Reduces errors due to random connection failures; a value of 1 will not retry after the first failure -->
    <read_timeout>10</read_timeout>         <!-- Set read timeout duration; phpredis does not currently support setting read timeouts -->
    <automatic_cleaning_factor>0</automatic_cleaning_factor> <!-- Disabled by default -->
    <compress_data>1</compress_data>  <!-- 0-9 for compression level, recommended: 0 or 1 -->
    <compress_tags>1</compress_tags>  <!-- 0-9 for compression level, recommended: 0 or 1 -->
    <compress_threshold>20480</compress_threshold>  <!-- Strings below this size will not be compressed -->
    <compression_lib>gzip</compression_lib> <!-- Supports gzip, lzf, lz4 (as l4z) and snappy -->
    <use_lua>0</use_lua> <!-- Set to 1 if Lua scripts should be used for some operations -->
  </backend_options>
</cache>

Redis is running and listening on unix socket:

port 0
 unixsocket /tmp/redis6380.sock

However, socket connection works fine with redis itself:

redis-benchmark -q -n 10000 -s /tmp/redis6380.sock
PING_INLINE: 54945.05 requests per second
PING_BULK: 70422.53 requests per second
SET: 81300.81 requests per second
GET: 72463.77 requests per second
INCR: 66666.66 requests per second
LPUSH: 60606.06 requests per second
LPOP: 59171.60 requests per second
SADD: 63694.27 requests per second
SPOP: 81300.81 requests per second
LPUSH (needed to benchmark LRANGE): 88495.58 requests per second
LRANGE_100 (first 100 elements): 38461.54 requests per second
LRANGE_300 (first 300 elements): 12091.90 requests per second
LRANGE_500 (first 450 elements): 5592.84 requests per second
LRANGE_600 (first 600 elements): 9737.10 requests per second
MSET (10 keys): 54945.05 requests per second

Magento log contains following:

ERR (3): Notice: Undefined index: port  in /home/username/public_html/lib/Cm/Cache/Backend/Redis.php on line 96

and

a:4:{i:0;s:44:"Connection to Redis failed after 2 failures.";i:1;s:1473:"#0 /home/username/public_html/lib/Credis/Client.php(362): Credis_Client->connect() 

If I missed something or misunderstood, please correct me. loca.xml setting - specifying the socket with no CDATA results same.

Thanks in advance for help and btw great thing :+1:

colinmollenhour commented 10 years ago

The PHP notice was addressed in 19155619 so please update to the latest and close the ticket if it resolves your issue.

zafarella commented 10 years ago

Patched mentioned file - same issue.