Redis

Install Redis 2.6.12 on Slackware64 14

SlackBuild Redis page http://slackbuilds.org/repository/14.0/system/redis/.

Build SlackBuild for Redis 2.6.12:

Built package for Slackware64 14: redis-2.6.12-x86_64-1_SBo.tgz

Install Redis 2.6.14 on Slackware 14

SlackBuild Redis page http://slackbuilds.org/repository/14.0/system/redis/.

Build SlackBuild for Redis 2.6.14:

Built package for Slackware 14: redis-2.6.14-i486-1_SBo.tgz

Start Redis service on Slackware

Run the following commands:

It listens in port 6379 and stores it's data on /var/lib/redis/, as configured in /etc/redis.conf.

Tutorial The Little Redis Book

Tutorial in http://openmymind.net/redis.pdf.

Connect to a Redis server

To connect to a Redis server, the redis-cli command may be used.

Usage examples:

Setting and getting keys

The basic anatomy of a command is:

To set a key named unixcommand:bc with the value {command:'bc' , description:'bc - An arbitrary precision calculator language' , syntax:'bc [ -hlwsqv ] [long-options] [ file ... ]'} the command would be:

To get the key value the command would be:

Redis hash key

Set an hash key with multiple keys with values:

Gets key values for an hash key:

Get all keys and values for an hash key:

Get keys for an hash key:

Get keys for an hash key:

Delete key from an hash key:

Redis list

Python client

   1 python
   2 import redis
   3 r = redis.StrictRedis(host='localhost', port=6379, db=0)
   4 r.rpush('queueA','test')
   5 r.rpush('queueA','test2')
   6 r.rpop('queueA')
   7 r.rpop('queueA')
   8 r.rpush('queueA', {'key':1234}  )
   9 x=r.pop('queueA')
  10 #convert string to dictionary
  11 import ast
  12 dictx=ast.literal_eval(x)
  13 dictx
  14 dictx['key']

Redis (last edited 2013-09-13 19:46:11 by 188)