I have the following hash:
HMSET rules:1231231234_11:00_17:00 fw 4444 dm test.abc.com days 'thu, tue, wed'
HMSET rules:1231231234_9:00_10:59 fw 2211 dm anothertest.abc.com days 'thu'
Is there anyway I can search the rules hash and find all records that have a prefix of 1231231234? Something like
HGET rules:1231231234*
OR... perhaps the way I've created the data is wrong. What's the best way to create a data set like this: (json notation)
{
pn: 1231231234,
rules: [{
"expiration_date" : "",
"days_of_week" : "Thu, Tue, Wed",
"start_time" : "11:00",
"end_time" : "17:00",
"fw" : "9999"
},
{
"rule_expiration_date" : "",
"days_of_week" : "Thu",
"start_time" : "9:00",
"end_time" : "10:59",
"fw" : "2222"
}]
}
How this data will be used:
I will need to find the rule that applies to me, based on the current time. So for example, when my application gets a request to "process" pn 1231231234, I need to lookup all rules for that pn number, and then find which rule matches my current day of week, and time stamp.
I don't mind getting back all the rules for a given pn and then having the client code loop through to find the right rule.
EDIT 1
Using my data the way it currently has been created, I tried HSCAN like this:
127.0.0.1:6379[1]> HSCAN rules 0 MATCH 1231231234*
1) "0"
2) (empty list or set)
127.0.0.1:6379[1]>
EDIT 2
As a test, I tried this type of a structure instead:
HMSET rules:1231231234 tue_11:00_17:00 fw 9999
HMSET rules:1231231234 wed_11:00_17:00 fw 9999
HMSET rules:1231231234 thur_11:00_17:00 fw 9999
HMSET rules:1231231234 thu_9:00_10:59 fw 2222
Then I can just see all rules for the main pn. and the use my client app to loop through the results... ?