Redis


Hash

HSET colors white fffff
HSET colors black 000000
HSET colors blue 0000FF
HGET colors white
HDEL colors white

List

LPUSH tasks task1
LPUSH tasks task2
RPUSH tasks task3
RPOP tasks # removes and get last element in list
LPOP tasks # removes and get first element in list
LRANGE tasks 5 10 # returns elements in specified range
BRPOP tasks # blocking RPOP
BLPOP tasks # blocking LPOP
LLEN tasks # list length

Set

SADD colors white
SADD colors black
SADD colors black
SADD colors blue
SREM colors white
SMEMBERS myset

SortedSets

Takes score and sort by that

String

SET welcomeMessage "Hello"
APPEND welcomeMessage " World"

SET masterServer host123 EX 60 NX # EX - Set the specified expire time, in seconds
                                  # PX - Set the specified expire time, in milliseconds
                                  # NX - Only set the key if it does not already exist.
                                  # XX - Only set the key if it already exist.

MISC

FLUSHALL
FLUSHDB

Use Cases