Basics of Redis

Basics of Redis

REDIS is an in-memory data structure store used as a database, cache, message broker, and streaming engine.

How to install Redis?

To install redis on your Linux machine follow the following commands:-

$ wget http://download.redis.io/releases/redis-4.0.6.tar.gz
$ tar xzf redis-4.0.6.tar.gz
$ cd redis-4.0.6
$ make
$ make install

After installation run

$ redis-server
$ redis-cli
$ redis-cli -h 127.0.0.1 -p 6379 -a 'thisizmy!PASS'

STRING

SET servername "ngnix"
GET servername => ngnix
EXISTS servername => 1
EXISTS serverblabla  => 0

INCR / DECR / DEL / INCRBY /DECRBY

 SET connections 10
 INCR connections => 11
 INCR connections => 12
 DEL connections


 INCRBY connections 100 => 101
 DECR connections => 100
 DECRBY connections 10 => 90

LIST

RPUSH / LPUSH / LRANGE / LLEN / RPOP / LPOP

 LPUSH tutorial mongo
 LPUSH tutorial redis
 LRANGE tutorial 0 9
 RPUSH tutorial db
 LSET tutorial 1 sql
 LLEN tutorial

SETS

SADD / SEMEMBERS / SREM / SCARD / SISMEMBER

SADD set1 member1
SADD set1 member2 member3
SMEMBERS set1
SCARD set1
SREM set1 member1
SISMEMBER set1 mem1