RedisErwin van der Koogh - Erronis
Warning!This is not about how blazingly fast RedisisOr how many keys it can storeThis is for a prototype. Our load is less...
What is Redis?Simple In-memory key-value storeWith a twistComplex data structuresStrong persistencePowerful control flowsEx...
ProblemAPI for Electronic Programming GuideComplete dump of upcoming 7 days everyhourBuild 10 days of historyFlexible quer...
First solution - ImportRead in dump, convert to JSONStore channelId in Set channelsMake a SortedSet for channelStore JSON ...
First solution - QueryGet all channelIds for Set channelsGet all items between begin and end fromSortedSetreturn
Problem 2That was fine for the first import, but theimport 1 hour later had to overwrite most ofthe data
Second solutionAdd new entries in a temp SortedSetTake date/time from first entry in SortedSetCopy current SortedSet to mer...
Problem 3We needed to update some of the dataUpdating complex entries (JSON) in a(Sorted)Set is error-prone
Third Solution - Import Instead of saving JSON in SortedSet save them in a hash Put only the key of the hash in the Sorted...
Third Solution - Query Get all channelIds from channel Set Get all Ids for entries between begin & end Get all information...
Lessons LearnedIn-memory makes a difference, lots ofqueries are okLearn to love single-threadedUse the complex data-struct...
Upcoming SlideShare
Loading in …5
×

How I used Redis' SortedSets

1,850 views
1,691 views

Published on

A quick presentation not so much on how spectacular the Redis performance is, but how quickly you can get stuff done and how I did it.

The presentation as I gave at the Dutch NoSQL Meetup on Wednesday April 11. http://www.meetup.com/nosql-nl/events/55488462/

Published in: Technology, Business
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,850
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
9
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • How I used Redis' SortedSets

    1. 1. RedisErwin van der Koogh - Erronis
    2. 2. Warning!This is not about how blazingly fast RedisisOr how many keys it can storeThis is for a prototype. Our load is less thana request/min and we have < 100.000 keysThis is to show how easy it is to use Redis indevelopment to knock something up.
    3. 3. What is Redis?Simple In-memory key-value storeWith a twistComplex data structuresStrong persistencePowerful control flowsExtremely fast
    4. 4. ProblemAPI for Electronic Programming GuideComplete dump of upcoming 7 days everyhourBuild 10 days of historyFlexible query options begin= & end=Hundreds of channels
    5. 5. First solution - ImportRead in dump, convert to JSONStore channelId in Set channelsMake a SortedSet for channelStore JSON with date/time as score
    6. 6. First solution - QueryGet all channelIds for Set channelsGet all items between begin and end fromSortedSetreturn
    7. 7. Problem 2That was fine for the first import, but theimport 1 hour later had to overwrite most ofthe data
    8. 8. Second solutionAdd new entries in a temp SortedSetTake date/time from first entry in SortedSetCopy current SortedSet to merge SortedSetRemove items in merge Set newer than firstnew entryMerge merge and tmp SortedSet into newSortedSet
    9. 9. Problem 3We needed to update some of the dataUpdating complex entries (JSON) in a(Sorted)Set is error-prone
    10. 10. Third Solution - Import Instead of saving JSON in SortedSet save them in a hash Put only the key of the hash in the SortedSet
    11. 11. Third Solution - Query Get all channelIds from channel Set Get all Ids for entries between begin & end Get all information from hash for every id Start streaming every item in as they are coming in
    12. 12. Lessons LearnedIn-memory makes a difference, lots ofqueries are okLearn to love single-threadedUse the complex data-structure for easyquerying (List, Set, SortedSet)MONITOR is your friend

    ×