Redis es un almacén de clave-valor que permite almacenar diferentes tipos de datos como cadenas, hashes, listas, conjuntos y conjuntos ordenados. Redis se caracteriza por ser rápido, escalable y permitir la persistencia de datos. Incluye características como publicación-suscripción que permiten la propagación de datos en tiempo real.
5. Strings
¡ The most simple data type
¡ Common Commands
¡ SET/GET (MSET/MGET)
¡ INCR/DECR
¡ INCRBY /INCRBYFLOAT
¡ DECRBY / DECRBYFLOAT
¡ STRLEN
6. Use Cases
¡ Simple caching with expiration
¡ Counts & Sums using INCRBY/DECRBY
SET
blog_count
10
INCR
blog_count
GET
blog_count
“11”
7. Hashes
¡ Similar to Ruby & Python hashes
they are maps with keys & values
¡ Common Commands
¡ HSET / HGET
¡ HGETALL
¡ HINCRBY / HINCRBYFLOAT
8. Use Cases
¡ Good for representing objects and storing data types
other than strings and integers
HSET
myhash
field1
"Hello”
field2
“Everyone”
HGET
myhash
field1
“HELLO”
9. Lists
¡ Basically linked lists from left to right.
¡ You can push and pop elements
Accessing data in the middle
isn’t as fast
¡ Common Commands
¡ LSET/LINDEX
¡ LPUSH/LPOP
¡ RPUSH/RPOP
¡ LINSERT
¡ LRANGE
11. Sets
¡ Unordered collections of unique elements
¡ Find differences between two sets, union of two
sets …
¡ Common Commands
¡ SADD/SREM
¡ SMEMBERS
¡ SISMEMBER
¡ SUNION
¡ SPOP
12. Use Cases
¡ Tagging systems
¡ Tracking unique visitors
¡ Getting random elements from a collection
13. Sorted Sets
¡ Similar to Sets but each key should have a score to get
sorted
¡ Common Commands
¡ ZADD/ZREM
¡ ZCOUNT
¡ ZINCRBY
¡ ZRANK
¡ ZRANGE
¡ ZSCORE
14. Use cases
¡ Leaderboards
¡ Notification systems
¡ Autocomplete searches
¡ Activity feeds based on a score or time and more..
15. Pub/Sub
¡ Redis supports real time data propagation.
¡ Users can subscribe to a “channel” and any message
sent to the channel will be published to all subscribers
at the same time.