To many on the outside, Redis looks like your average key-value store. To those in the know, Redis is a powerful data structure store that’s capable of doing much of what a full-featured database can handle.
In this talk, Ryan will give a quick overview of Redis’ API and the datatypes it allows you to store and query. He’ll then take you through the process of designing a complex schema with Redis and demonstrate how using simple data structures can help you in making better decisions for your applications.
33. Data in RDBMS
id first_name last_name login
1 Ryan Briones ryanbriones
... ... ... ...
34. Data in Redis
INCR users:uids
“1”
SET users:1:first_name Ryan
OK
SET users:1:last_name Briones
OK
SET users:1:login ryanbriones
OK
35. Data in RDBMS
id first_name last_name login
1 Ryan Briones ryanbriones
... ... ... ...
36. Data in Redis
KEYS users:1:*
1) users:1:first_name
2) users:1:last_name
3) users:1:login
GET users:1:first_name
“Ryan”
GET users:1:last_name
“Briones”
GET users:1:login
“ryanbriones”
42. Data in Redis
users:uids 1
users:1:first_name Ryan
users:1:last_name Briones
users:1:login ryanbriones
users:all {1}
users:login:ryanbriones:uid 1
43. Data in Redis
SET users:last_name:Briones:uid 100
1 OK
SADD users_last_names Briones
OK
SET users:last_name:Andrews:uid 200
2 OK
SADD users_last_names Andrews
OK
SORT users_last_names ALPHA DESC BY *
GET users:last_name:*:uid
1) 100
2) 200
44. Data in Redis
SORT users_last_names ALPHA DESC BY *
GET users:last_name:*:uid
STORE users_uid_by_last_name_desc
(integer) 2
TYPE users_uid_by_last_name_desc
list
LRANGE users_uid_by_last_name_desc 0 -1
1) 200
2) 100
46. Data in RDBMS
id first_name last_name login
1 Ryan Briones ryanbriones
... ... ... ...
id title body permalink user_id
10 Redis Rocks ... redis-rocks 1
... ... ... ... ...
47. Data in Redis
SET posts:10:title “Redis Rocks”
OK
SET posts:10:body “Lorem ipsum..”
OK
SET posts:10:permalink “redis-rocks”
OK
SET posts:10:user_id 1
OK
SET posts:permalink:redis-rocks:id 10
OK
SADD posts:all 10
OK
48. Data in Redis
SET posts:10:title “Redis Rocks”
OK
SET posts:10:body “Lorem ipsum..”
OK
SET posts:10:permalink “redis-rocks”
OK
SET posts:10:user_id 1
OK
SET posts:permalink:redis-rocks:id 10
OK
SADD posts:all 10
OK
LPUSH users:1:posts 10
OK
49. Data in Redis
SET posts:10:title “Redis Rocks”
OK
SET posts:10:body “Lorem ipsum..”
OK
SET posts:10:permalink “redis-rocks”
OK
SET posts:10:user_id 1
OK
SET posts:permalink:redis-rocks:id 10
OK
SADD posts:all 10
OK
ZADD users:1:posts 1307463108973.28 10
OK
50. Data in Redis
SORT user:1:posts DESC
GET posts:*:title
GET posts:*:permalink
1) “Redis Rocks”
2) redis-rocks