Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

RedisConf18 - Redis Data Structures for Non Redis People

322 views

Published on

Redis Labs Session

Published in: Technology
  • Be the first to comment

RedisConf18 - Redis Data Structures for Non Redis People

  1. 1. • • • •
  2. 2. I learnt to "translate"I drove on this side of the road I really ate these things
  3. 3. { 'sku': "123-ABC-723", 'name': "Men's 100m Final", 'disabled_access': True, 'medal_event': True, 'venue': "Olympic Stadium", 'category': "Track & Field", 'capacity': 60102, 'available': { 'general': { 'qty': 20000, 'price': 25.00 } } } <?xml version="1.0"?> <event_catalog> <event> <sku="123-ABC-723"> <name>Men's 100m Final</name> <disabled_access>true</disabled_access> <medal_event>true</medal_event> <venue>Olympic Stadium</event> <category>Track & Field</category> <capacity>60102</capacity> <available> <general> <qty>20000</qty> <price>25.00</price> </general> </available> </event> </event_catalog>
  4. 4. … • • • • •
  5. 5. event:Judo "Sold Out" String List Set Sorted Set Hash Key Name Basic Data typeValue
  6. 6. event:Judo ● ● ● Key Name
  7. 7. event:Judo ● ● ● ○ ○ ○ ● ● event:venues event:Fencing event:fencing Event:fencing Key Name
  8. 8. event:Judo ● ● ○ ○ ○ ● ● 2event:Judo > pexpire event:Judo 2 > set event:Fencing ex 50 event:Fencing 50 Key Name Expiration
  9. 9. event:Judo "Sold Out" embstr > set event:Judo "Sold Out" > set event:Judo 42 event:Judo "42" int > set event:Judo 3.14159 event:Judo "3.14159" embstr Key Name EncodingValue
  10. 10. event:Fencing 42 Key Name ✅int Encoding > incr event:Fencing event:Judo "Sold Out" embstr > incr event:Judo ❌ String Data type String events Fencing, Judo List > incr events ❌ Value
  11. 11. events ● ● ● ○ Key Name "Judo" Left "Fencing" "Taekwondo" Right > lpop events "Judo" > rpop events "Taekwondo"
  12. 12. • • • • • • • • •
  13. 13. events ● ● ○ ○ ○ Key Name "Fencing" "Taekwondo" "Judo" > smembers events 1) "Judo" 2) "Taekwondo" 3) "Fencing" Member/Element
  14. 14. • • • • • • •
  15. 15. events ● ● ● ○ ○ Key Name "Fencing" "Taekwondo" "Judo" > zrange events 0 1 1) "Fencing" 2) "Judo" Value 2 3 1 Score
  16. 16. • • • • • •
  17. 17. event:Judo ● ● ● Key Name True 32000 Super Dome > hget event:Judo capacity "32000" Value capacity subway Score venue
  18. 18. • • • • • • •
  19. 19. … …
  20. 20. { 'sku': "123-ABC-723", 'name': "Men's 100m Final", 'disabled_access': True, 'medal_event': True, 'venue': "Olympic Stadium", 'category': "Track & Field", 'capacity': 60102, 'available': { 'general': { 'qty': 20000, 'price': 25.00 } } }
  21. 21. • • • • • • •
  22. 22. > set event:event:123-ABC-723 "{"sku": "123-ABC-723", "category": "Track & Field", "available": {"general": {"price": 25.0, "qty": 20000}}, "capacity": 60102, "name": "Men's 100m Final", "disabled_access": true, "medal_event": true, "venue": "Olympic Stadium"}" ● ○ ○ ● ○ ○ ■ ■ ○ ■ ○
  23. 23. > hmset event:123-ABC-723 sku "123-ABC-723" name "Men's 100m Final" disabled_access True medal_event True venue "Olympic Stadium" category "Track & Field" capacity 60102 available:general:qty 20000 available:general:price 22.50 ● ● ○ ● ○ ○ ● ○
  24. 24. > hmset event:123-ABC-723 sku "123-ABC-723" name "Men's 100m Final" disabled_access True medal_event True venue "Olympic Stadium" category "Track & Field" capacity 60102 available:general:qty 20000 available:general:price 22.50 ● ○ ○ ● ○
  25. 25. > hmset event:123-ABC-723 sku "123-ABC-723" name "Men's 100m Final" disabled_access True medal_event True venue "Olympic Stadium" category "Track & Field" capacity 60102 > hset event:123-ABC-723:general qty 20000 price 22.50 > sadd event:123-ABC-723:available event:123-ABC-723:general ● ○ ○ ● ○ ○
  26. 26. > hmset event:123-ABC-723 sku "123-ABC-723" name "Men's 100m Final" disabled_access True medal_event True venue "Olympic Stadium" category "Track & Field" capacity 60102 > hset event:123-ABC-723:general qty 20000 price 22.50 > sadd event:123-ABC-723:available event:123-ABC-723:general ● ○ ○ ● ○ ○
  27. 27. • • • • • > multi > set event:Judo 100 > incr event:Judo > exec > multi > set event:Judo "Sold Out" > discard
  28. 28. multi incr event:Judo get event:Judo exec Client 1 get event:Judo get event:Judo Client 2 100 100 set event:Judo 100 incr event:Judo 101 get event:Judo 101 Time
  29. 29. multi incr event:Judo get event:Judo exec Client 1 decr event:Judo get event:Judo 100 99 99 set event:Judo 100 incr event:Judo 100 get event:Judo 100 Time
  30. 30. • •
  31. 31. watch event:Judo incr event:Judo exec Client 1 set event:Judo 200 Client 2 100 200 event:Judo 100 get event:Judo 200 nil ❌
  32. 32. • •
  33. 33. ● ● ○ ○ ● > geoadd venues 139.75 35.693333 "Nippon Budokan"
  34. 34. > georadius venues 139.606396 35.509996 25 km 25 KM ● ○ ● ○ ○ ○ 139.606396 35.509996
  35. 35. > georadiusbymember venues "Nippon Budokan" 1500 m 1500 m ● ○ ● ○ ○ ○ Nippon Budokan
  36. 36. > geodist venues "Makuhari Messe" "Nippon Budokan" km 26.2093 KM ● ○ ● ○ ○ Makuhari Messe Nippon Budokan
  37. 37. • • • • • • • •
  38. 38. ● ● ○ ○ > publish news:Judo "Event starts in 1 hour" > subscribe news:Judo > unsubscribe news:Judo > psubscribe news:*
  39. 39. publish news:Judo "Medal event about to start" Client 1 "Medal event about to start" Client 2 subscribe news:Judo news:Judo publish news:Judo "Event starting" "Event Starting" publish news:Judo "Event finished" "Event Finished" "Event Finished" Time
  40. 40.
  41. 41. • • • • • • • •
  42. 42. • •
  43. 43. … • • • • • • • •
  44. 44. event:Judo ● ○ ● ● Key Name

×