I'm coming from mysql, trying to wrap my head around redis. Some things were very obvious but a couple have me stumped. How would you go about implementing such things in redis?
First
I have a sort of first come/first serve reservation system. When a user goes to a specific page, it queries the table below and returns the first badge
where reservedby
= 0, it then updates reservedby
with the users id. If the user doesn't complete the process within 15 minutes, reservedby
is reset to 0
. If the user completes the process, I delete the row from the table and store the badge
with the user data. Order is important, the higher on the list a badge is, the better, so if I were to remove it instead of somehow marking it reserved, it would need to go back in on the top if the process isn't completed with 15 minutes.
id | badge | reservedby
------------------------
240 | abc | 4249
241 | bbb | 0
242 | rrr | 0
Second
I have a set of data that doesn't change very often but is queried a lot. When a page loads, it populates a select box with each color
, when you select a color, the corresponding sm
and lg
are displayed.
id | color | sm | lg
---------------------------
1 | blue | 1 | 5
2 | red | 3 | 10
3 | yellow | 7 | 8
Lastly
As far as storing user data, what I'm doing is INCR users
and then taking that value and hmset user:<INCR users value> badge "aab" joindate "10/30/2013"
etc, is that typically how it should be done?