问题描述:

I am trying to store something like the following...

I have a system which has keywords, these keywords can be right or wrong. I want to store the every time someone enters a wrong keyword (as well as the specific application they where on and a timestamp).

timestamp - application#1 and I'd like it to be inside it's own key.

I need to then be able to go "Okay how many people got a keyword wrong between TIMESTAMP1 and TIMESTAMP2 that tried using application #1"

Is there any other way I could do this? If the last part (that tried using application #1) won't work which I suspect as this isn't SQL. Then could it return the value of application #1 so I can do the last part in PHP.

Thanks!

网友答案:

Redis does not support key wildcards so you have to select the keys client side.

This means you have to get batches of keys and combine the results together; if thats not always possible (eg. big ranges, ms key naming resolution...) you should consider keeping aggregates (keyword per hour / keyword per day ...)

If you use sets / sorted sets to store the keywords have a look at the set specific commands (UNION / UNIONSTORE in specific) as they might come handy for this :)

相关阅读:
Top