Redis

https://redis.io/

Key-value in-memory data store used as a

Install Redis 2.6.12 on Slackware64 14

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

Build SlackBuilds for Redis 2.6.12:

   1 cd /tmp
   2 wget http://slackbuilds.org/slackbuilds/14.0/system/redis.tar.gz
   3 tar xvzf redis.tar.gz
   4 cd redis
   5 wget http://redis.googlecode.com/files/redis-2.6.12.tar.gz
   6 su
   7 ./redis.SlackBuild
   8 installpkg /tmp/redis-2.6.12-x86_64-1_SBo.tgz

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

Install Redis 2.6.14 on Slackware 14

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

Build SlackBuilds for Redis 2.6.14:

   1 su
   2 cd /tmp
   3 wget http://slackbuilds.org/slackbuilds/14.0/system/redis.tar.gz
   4 tar xvzf redis.tar.gz
   5 cd redis
   6 wget http://redis.googlecode.com/files/redis-2.6.14.tar.gz
   7 ./redis.SlackBuild
   8 installpkg  /tmp/redis-2.6.14-i486-1_SBo.tgz

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

Start Redis service on Slackware

Run the following commands:

   1 chmod 755 /etc/rc.d/rc.redis # start on boot
   2 /etc/rc.d/rc.redis start

Manual start/stop:

   1 sh /etc/rc.d/rc.redis start
   2 sh /etc/rc.d/rc.redis stop  

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 show all keys use keys *

To get the type of a key use type keyName

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

Command prefix H.

Set an hash key with multiple fields with values:

Gets field values for an hash key:

Get all fields and values for an hash key:

Get fields for an hash key:

Get field for an hash key:

Delete field from an hash key:

Redis list

Command prefix L or R.

Examples:

Redis sorted set

Command prefix Z. Only allow unique members values on the sorted set. When a existing member is added, the score is updated.

Examples:

Python client install from pip

   1 su
   2 easy_install pip # if no pip installed
   3 pip install redis

Python client install from source

   1 su
   2 cd /tmp
   3 wget [[https://pypi.python.org/packages/source/r/redis/redis-2.8.0.tar.gz]]
   4 tar xvzf redis-2.8.0.tar.gz 
   5 cd redis-2.8.0
   6 python setup.py build
   7 python setup.py install

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

Install on FreeBSD 10.3

   1 pkg install redis #freebsd
   2 add redis_enable="YES" to /etc/rc.conf
   3 /usr/local/etc/rc.d/redis start
   4 
   5 /usr/local/etc/redis.conf
   6 requirepass 12345678

Install redis in debian

   1 sudo apt install redis
   2 redis-cli

Redis (last edited 2023-05-26 11:42:56 by 127)