hackpar / redis

Automatically exported from code.google.com/p/redis
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

[Feature Request] MAP command #574

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I propose a new command that operates on sets, lists, and hashes, or any other 
type of collection.

The command maps items from a collection to other redis commands.

i.e. MAP 'user:1:friends' HGETALL 'user:*'
  where * is replaced by the items in the set 'user:1:friends'.

Original issue reported on code.google.com by james.keane on 4 Jun 2011 at 11:34

GoogleCodeExporter commented 8 years ago
For sets and lists...
SORT <set|list> BY nosort GET user:*->field

Will get a single field. You can have multiple GET options to get multiple 
fields. Considering that the scripting branch will make this particular kind of 
thing easy (what you really want is the HGETALL, I am sure), it's probably not 
going to make it.

Original comment by josiah.c...@gmail.com on 5 Jun 2011 at 4:39

GoogleCodeExporter commented 8 years ago
But be aware that SORT doesn't keep order of keys as they stored in Sorted Set 
when it is used to select objects by keys with option 'BY nosort'.

See for details: 
http://groups.google.com/group/nosql-databases/browse_thread/thread/f41e601c4e3e
49fc/b7a56e9427a8cc49#b7a56e9427a8cc49

So you actaully need to use SORT instead of MAP but use it with care.

Original comment by Alfiia.M...@gmail.com on 6 Jun 2011 at 8:02

GoogleCodeExporter commented 8 years ago
That's because it pulls the keys from the hash portion of the sorted set, not 
from the skiplist portion of the sorted set. If you want to get the ids, you 
would include a "GET #" portion for the SORT call.

Original comment by josiah.c...@gmail.com on 6 Jun 2011 at 9:49