zjjfly / redis

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

Feature request: copy list key with rename #247

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
May be is something the client should do by itself, but let's say I have a 
key k1 containing a list, I would like to copy k1 into k2 (also of type 
list) to later modify k2 without touching k1. Kind of

k2 = k1;
rpush k2 "blah blah"

I have not touch about the side-effects it could have in other types of key 
types. I think for normal keys it has no sense, but for lists it might have 
sense to avoid sending the list to the client and back to the server.

Thanks
Juan

Original issue reported on code.google.com by juan.aba...@gmail.com on 24 May 2010 at 11:12

GoogleCodeExporter commented 8 years ago
This would be great for sets, zsets and hashes as well.

Consider a series of processes that all add elements to a set. Periodically you 
want to process all the elements in that set with a distributed set of 
consumers:

publisher_a: sadd my_key 1
publisher_b: sadd my_key 2
publisher_a: sadd my_key 3
batch_manager: copy my_key my_batch
consumer_a: spop my_batch
consumer_b: spop my_batch
consumer_a: spop my_batch

# The consumers can process all of the elements that were in 'my_key' at the 
time of the 'copy' - perfect for periodically processing snapshots of data, 
while continuing to maintain a pristine original at 'my_key'

Original comment by brianoro...@gmail.com on 21 Jun 2010 at 9:16

GoogleCodeExporter commented 8 years ago
Agreed, another use case is when a scored set is used to represent correlation 
between keywords and classes (e.g. sports) and the copy is intended to 
eventually represent a sub-class (e.g. basketball).

Original comment by dr.marc....@gmail.com on 6 Apr 2011 at 1:56

GoogleCodeExporter commented 8 years ago
See my comment on bug 418 for set/zset.

Original comment by josiah.c...@gmail.com on 6 Apr 2011 at 5:25