0

I Got the following kind of data stored on redis

{"
    {"userId":"00001","userName":"You","xp":0,"type":"element","honor":500, "position":2}":"2",
   "{"userId":"00002", "userName":"Another","xp":0,"type","honor":500,"position":1}":"1"
}

So I need to retrieve the score (or the position value) searching by the userId (Ej: userId : 00001 have to return 1)

I have try with zscore (something like rank:userId (id)) but that not work.

I have search on google but i only found examples with simples (score : value) pairs

Pete
  • 57,112
  • 28
  • 117
  • 166
Morgoth
  • 15
  • 7
  • You've stored the json above as the value of an zset? – RienNeVaPlu͢s Sep 22 '14 at 20:52
  • yes i add in that way – Morgoth Sep 22 '14 at 20:53
  • Try to store the userId as the sets score if you can. Afaik there is no (reasonable) way of searching inside the value of a zset, without reading the whole set. – RienNeVaPlu͢s Sep 22 '14 at 20:59
  • I already try it, but the userId is a really long string and it appears cutted when i retrieve the info, but i will try again just in case i do something wrong – Morgoth Sep 22 '14 at 21:00
  • Have a look at [this question](http://stackoverflow.com/questions/16886603/redis-get-vs-sql-select) (disclosure: I've asked that.) You might be able to use the described model for your purpose. – RienNeVaPlu͢s Sep 22 '14 at 21:21

0 Answers0