About
Redis is an open source (BSD licensed), in-memory key-value data store used as:
- database,
- and message broker.
Articles Related
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
Management
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
- To get the information, run a equality query (HGETALL) for each key.
The same idea can be used to perform theta join (complex join)