Services     Software     Commentary     Design     Astral Musings   
redis, memcache
Configuration tips

rickatech 2016-09 (edit)


As of 2016 Redis has become the defacto memory cache for supporting all manner of web services, essentially replacing venerable memcache.

# yum install redis

# yum install php-pecl-redis

# systemctl status redis   


Most web servers default to storing web session state directly on local file system.  Redis can be used to store sessions in memory instead.  PHP is a popular service session framework, and it can be configured to detext and use redis service instead of local file store for sessions state.

# yum install redis

# yum install  php56w-pecl-redis

# diff /etc/httpd/conf.d/php.conf

< php_value session.save_handler "files"
< php_value session.save_path    "/var/lib/php/session"
< php_value soap.wsdl_cache_dir  "/var/lib/php/wsdlcache"
> php_value session.save_handler "redis"
> php_value session.save_path    "tcp://"
> php_value soap.wsdl_cache_dir  "tcp://"

# systemctl restart redis

# systemctl restart httpd 

$ cat .../session.php 

  <?php  //simple session counter for testing
  $count = isset($_SESSION['count']) ? $_SESSION['count'] : 1;
  echo $count;
  $_SESSION['count'] = ++$count;

$ redis-cli -h localhost

  > keys *

    1) "PHPREDIS_SESSION:fepl2i5rm53gn58qq8ii7tbi07"  
fredness 2011 (edit)


Installing with yum ...

Check for reasonably latest release for your architecture.

# rpm -Uhv

# wget

# rpm -ivh perl-Net-SSLeay-1.36-1.el5.rfx.i386.rpm


# yum install memcached


    memcached.i386 0:1.4.5-1.el5.rf

  Dependency Installed:
    compat-libevent-11a.i386 0:3.2.1-1.el5.rf
    perl-AnyEvent.noarch 0:5.240-1.el5.rf
    perl-EV.i386 0:3.9-1.el5.rf
    perl-Guard.i386 0:1.021-1.el5.rf
    perl-JSON.noarch 0:2.50-1.el5.rf
    perl-JSON-XS.i386 0:2.30-1.el5.rf
    perl-TermReadKey.i386 0:2.30-3.el5.rf
    perl-YAML.noarch 0:0.72-1.el5.rf
    perl-common-sense.i386 0:3.0-1.el5.rf


# memcached -h

  memcached 1.4.5

# yum install php-pecl-memcache


# service httpd restart

  Stopping httpd: [  OK  ]
  Starting httpd: [  OK  ]

# service memcached status

  memcached is stopped

# service memcached start

  Starting Distributed memory caching (memcached): [  OK  ]

# ps -e | grep memcached

  2076 ? 00:00:00 memcached 
zap technologies
tablet | printable