php - redis json sql style query -


i have bunch of json store in redis

{     "foo": "37",     "bar": "alex",     "baz": "tom",     "type": "test",     "date": "12/12/2012 12:12:12 } 

but coming sql background, i'm not sure best way go doing:

select * table "foo" = "37" , "baz" = "test" order date desc 

i've looked @ hashes, i'm unclear if redis able perform queries 1 above?

the way go redis build indices. example, consider following flow "insert" data hash key , build proper indices:

hmset somekeyname foo "37" bar "alex" baz "tom" type "test" date "12/12/2012 12:12:12" sadd foo_index:37 somekeyname sadd baz_index:test somekeyname 

this create key called somekeyname of type hash relevant data in it. additionally, create/update 2 sets we'll use indices. now, keys match sql select statement, like:

sinter foo_index:37 baz_index:test 

this return key names fulfill conditions. sorting results can done @ client side or replacing sinter sinterstore , using redis' sort command on destination key.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -