esdc redis

secult edited this page Dec 8, 2016 · 9 revisions

Redis

Redis is an advanced key-value store.
http://redis.io/

Note: This guide is made for a development environment based on CentOS 7.

Install

We will use the remi repository and install the newest version (3.2):

yum install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

vim /etc/yum.repos.d/remi.repo  # Enable the [remi] repo

yum install redis

Configure

REDISPASS="S3cr3tP4ssw0rd"
vim /etc/redis.conf
  1. Comment out bind option
  2. Set requirepass ${REDISPASS}
  3. Comment out save lines (in SNAPSHOTTING section)

Edit iptables to add line for opening redis port

vim /etc/sysconfig/iptables

Add following line:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 6379 -j ACCEPT

Then restart iptables

systemctl restart iptables  # allow port 6379 for compute nodes 

Run

systemctl start redis
systemctl enable redis

Use

  • Used by django for caching:

    from django.core.cache import cache, caches
    
    # django cache wrapper
    cache.set(key, value, timeout=0)
    cache.get(key)
    cache.delete(key)
    
    # redis client directly
    redis = caches['redis'].master_client
    redis.keys()
  • Also used by Celery as a result backend:

    from que.erigonesd import cq
    
    redis = cq.backed.client
    redis.keys()
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.