Always see a lot of back and forth between Memcache and APC but havent seen much talk about Redis.

Noticed some talk about Magento performance and cache issues which brought up comparisons between Redis and File cache:
http://magebase.com/magento-tutorials/improving-the-file-cache-backend/

Im not sure how Redis stacks against Memcache or APC (and how those behave differently than the file cache) but since I went through the work of installing it on a test server and got it to work, figured I would lay out some steps on how to do it here.

Most of the instructions were followed from the github installation here:
https://github.com/colinmollenhour/Cm_Cache_Backend_Redis

Download and make Redis:

 

$ wget http://redis.googlecode.com/files/redis-2.4.11.tar.gz
$ tar xzf redis-2.4.11.tar.gz
$ cd redis-2.4.11
$ make

 

Move our main two redis files into the /usr/local/bin/

 

$ cd src
$ cp redis-server /usr/local/bin/
$ cp redis-cli /usr/local/bin/

 

Make folders to hold our our config/data info (note: 6379 is the port I am using redis on in this example)

 

$ mkdir /etc/redis
$ mkdir /var/redis
$ mkdir /var/redis/6379

 

Move the default init script and the default conf file

 

$ cp utils/redis_init_script /etc/init.d/redis_6379
$ cp redis.conf /etc/redis/6379.conf

 

Edit the config file

 

$ nano /etc/redis/6379.conf
- set daemonize to yes
- set pidfile to /var/run/redis_6379.pid
- set logfile to /var/log/redis_6379.log
- set dir to /var/redis/6379
- set maxmemory to some value appropriate for your system (otherwise it will gobble it all up)

 

Install and Make phpRedis

 

$ git clone git://github.com/owlient/phpredis
$ cd phpredis
$ phpize
$ ./configure
$ make && make install

 

Make/Edit your php redis.ini file

 

$ nano /etc/php.d/redis.ini
extension=redis.so

 

Get Colins Magento Redis code (this got a little messy since I didnt use his module symlinking git)

 

$ git clone git://github.com/colinmollenhour/Cm_Cache_Backend_redis.git
$ mv Cm_Cache_Backend_Redis/Cm/Cache/Backend/* /var/www/html/magento/app/code/community/Cm/Cache/Backend/

 

That unfortunately was missing the /lib/Credis/Client.php You can get the code from here:
https://raw.github.com/colinmollenhour/credis/master/Client.php
That code should go into a new folder/file called /var/www/html/magento/lib/Credis/Client.php file

With that all set, we now need to add it to our local.xml file

 

$ nano /var/www/html/magento/app/etc/local.xml
<!-- this is a child node of config/global -->
<cache>
<backend>Cm_Cache_Backend_Redis</backend>
<backend_options>
<server>127.0.0.1</server> <!-- or absolute path to unix socket for better performance -->
<port>6379</port>
<database>0</database>
<force_standalone>0</force_standalone>  <!-- 0 for phpredis, 1 for standalone PHP -->
<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 and snappy -->
</backend_options>
</cache>

 

$ service httpd restart

 

 /etc/init.d/redis_6379 start

 

Now you’re done and can enjoy your new fast redis caching server!