The Beauty of Simplicity: Mastering Database Design with Redis
Upcoming SlideShare
Loading in...5
×
 

The Beauty of Simplicity: Mastering Database Design with Redis

on

  • 8,338 views

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 ...

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.

Statistics

Views

Total Views
8,338
Views on SlideShare
8,330
Embed Views
8

Actions

Likes
15
Downloads
164
Comments
0

2 Embeds 8

http://speakerrate.com 7
http://www.docseek.net 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

The Beauty of Simplicity: Mastering Database Design with Redis The Beauty of Simplicity: Mastering Database Design with Redis Presentation Transcript

  • The Beauty of SimplicityMastering Database Design with
  • What is this talk about?
  • ChicagoDBhttp://chicagodb.com
  • 1 2 3
  • 1 2 3Basic Redis API
  • 1 2 3Simple Use Cases
  • 1 2 3Learning from Redis
  • SET the-answer 42OK
  • GET the-answer“42”
  • The End
  • 42 24
  • http://redis.io
  • ListsRPUSH primes 2(integer) 1RPUSH primes 3(integer) 2RPUSH primes 5(integer) 3
  • ListsLRANGE primes 0 -11) “2”2) “3”3) “5”
  • SetsSADD words foo(integer) 1SADD words bar(integer) 1SADD words foo(integer) 0
  • SetsSMEMBERS words1) “foo”2) “bar”
  • Sorted SetsZINCRBY words 1 foo“1”ZINCRBY words 1 bar“1”ZINCRBY words 1 foo“2”
  • Sorted SetsZREVRANGE words 0 -1 WITHSCORES1) “foo”2) “2”3) “bar”4) “1”
  • HashesHSET person first_name Ryan(integer) 1HSET person last_name Briones(integer) 1
  • HashesHGETALL person1) “first_name”2) “Ryan”3) “last_name”4) “Briones”
  • QueuesRPUSH queue foo(integer) 1RPUSH queue bar(integer) 2LPOP queue“1”
  • Set IntersectionSADD fb_friends 1234567(integer) 1SADD fb_friends 1234568(integer) 1SADD purchasers 1234567(integer) 1SINTER fb_friends purchasers1) 1234567
  • Chat Ser verZADD room 1307420357571.96 {:msg => “Hello Mike”}(integer) 1ZADD room 1307420462678.8 {:msg => “Hello Joe”}(integer) 1ZADD room 1307420496256.58 {:msg => “Hello World”}(integer) 1
  • Chat Ser verZREVRANGE room 0 301) {...}2) {...}ZRANGEBYSCORE room 1307420357571.96 +inf1) {...}
  • Application Data in Redis
  • Data in RDBMSid first_name last_name login1 Ryan Briones ryanbriones... ... ... ...
  • Data in RedisINCR users:uids“1”
  • Data in RDBMSid first_name last_name login1 Ryan Briones ryanbriones... ... ... ...
  • Data in RedisINCR users:uids“1”SET users:1:first_name RyanOKSET users:1:last_name BrionesOKSET users:1:login ryanbrionesOK
  • Data in RDBMSid first_name last_name login1 Ryan Briones ryanbriones... ... ... ...
  • Data in RedisKEYS users:1:*1) users:1:first_name2) users:1:last_name3) users:1:loginGET users:1:first_name“Ryan”GET users:1:last_name“Briones”GET users:1:login“ryanbriones”
  • Data in RDBMSSELECT * FROM users;
  • Data in RedisSADD users:all 1(integer) 1SMEMBERS users:all1) 12) ...
  • Data in Redis users:uids 1users:1:first_name Ryanusers:1:last_name Briones users:1:login ryanbriones users:all {1}
  • Data in RedisSET users:login:ryanbriones:uid 1OKGET users:login:ryanbriones:uid“1”
  • Data in RDBMSSELECT * FROM users ORDER BY last_name DESC;
  • 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
  • Data in Redis SET users:last_name:Briones:uid 1001 OK SADD users_last_names Briones OK SET users:last_name:Andrews:uid 2002 OK SADD users_last_names Andrews OK SORT users_last_names ALPHA DESC BY * GET users:last_name:*:uid 1) 100 2) 200
  • Data in RedisSORT users_last_names ALPHA DESC BY * GET users:last_name:*:uid STORE users_uid_by_last_name_desc(integer) 2TYPE users_uid_by_last_name_desclistLRANGE users_uid_by_last_name_desc 0 -11) 2002) 100
  • Data in RedisEXPIRE users_uid_by_last_name_desc 86400(integer) 1
  • Data in RDBMS id first_name last_name login 1 Ryan Briones ryanbriones ... ... ... ...id title body permalink user_id10 Redis Rocks ... redis-rocks 1... ... ... ... ...
  • Data in RedisSET posts:10:title “Redis Rocks”OKSET posts:10:body “Lorem ipsum..”OKSET posts:10:permalink “redis-rocks”OKSET posts:10:user_id 1OKSET posts:permalink:redis-rocks:id 10OKSADD posts:all 10OK
  • Data in RedisSET posts:10:title “Redis Rocks”OKSET posts:10:body “Lorem ipsum..”OKSET posts:10:permalink “redis-rocks”OKSET posts:10:user_id 1OKSET posts:permalink:redis-rocks:id 10OKSADD posts:all 10OKLPUSH users:1:posts 10OK
  • Data in RedisSET posts:10:title “Redis Rocks”OKSET posts:10:body “Lorem ipsum..”OKSET posts:10:permalink “redis-rocks”OKSET posts:10:user_id 1OKSET posts:permalink:redis-rocks:id 10OKSADD posts:all 10OKZADD users:1:posts 1307463108973.28 10OK
  • Data in RedisSORT user:1:posts DESC GET posts:*:title GET posts:*:permalink1) “Redis Rocks”2) redis-rocks
  • Sharding AOF Disk Persistence Cluster/DR Lua ScriptingPub-Sub Replication Simple Transactions
  • Ryan Briones@ryanbriones work for //obtiva