Table of Contents

About

Redis is an open source (BSD licensed), in-memory key-value data store used as:

Redis is an acronym for Remote Dictionary Server.

Data structures

  • Hash, (if you have objects representing users in a web application, instead of using different keys for name, surname, email, password, use a single hash with all the required fields)
  • Sorted Set
  • Set

More .. https://redis.io/topics/data-types-intro

Management

The below paragraph shows you the difference between SQL and Redis Query.

Insert

SQL:

insert into Products (id, name, description, price) values (10200, “ZXYW”,“Description for ZXYW”, 300);

Redis:

MULTI
HMSET product:10200 name ZXYW desc “Description for ZXYW” price 300
ZADD product_list 10200 product:10200
ZADD product_price 300 product:10200
EXEC

Get / Query

Equality

SQL:

select * from Products where id = 10200

Redis:

HGETALL product:10200

Range

SQL:

select * from Product where price < 300

Redis:

ZRANGEBYSCORE product_price 0 300
  • Returns the keys
HGETALL product:10001
HGETALL product:10002
HGETALL product:10003

The same idea can be used to perform theta join (complex join)

Annexes