How to allow duplicates

1,152 views
Skip to first unread message

Manula Thantriwatte

unread,
Feb 23, 2011, 3:25:16 AM2/23/11
to Redis DB
Sorted sets in Redis didn't allow duplicates. Can we allow duplicates in sorted sets ? 

--
Regards,
Manula Thantriwatte.
Undergraduate | University of Colombo School of Computing
Sri Lanka

Demis Bellot

unread,
Feb 23, 2011, 3:28:47 AM2/23/11
to redi...@googlegroups.com, Manula Thantriwatte
Are you sure you don't want to be using a LIST? As a SET by definition doesn't contain duplicates.

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To post to this group, send email to redi...@googlegroups.com.
To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.



--
- Demis


Didier Spezia

unread,
Feb 23, 2011, 4:18:24 AM2/23/11
to Redis DB
Hi,

if you are trying to build an ordered, non unique indexing
data structure, and are really stuck with Redis, you may
want to have a look at Jak Sprats' Alchemy Database.

http://code.google.com/p/alchemydatabase/

It remains mostly compatible with Redis, but may fit your
needs better due to its support for in-memory btree indexes.

Should you need to discuss about it, please use the
dedicated group.

Regards,
Didier.

On 23 fév, 09:25, Manula Thantriwatte <manulachathur...@gmail.com>
wrote:

Will Maier

unread,
Feb 23, 2011, 6:27:05 AM2/23/11
to redi...@googlegroups.com
Hi Manula-

On Wed, Feb 23, 2011 at 01:55:16PM +0530, Manula Thantriwatte wrote:
> Sorted sets in Redis didn't allow duplicates. Can we allow duplicates in
> sorted sets ?

The usual trick involves composing values in the set using the score. For time
series data, where the score is a timestamp and the value is a number, this
should be enough to preserve the unique-ness of potentially repeating values.
Eg:

ZADD time.series 1298460338 "1298460348 9"
ZADD time.series 1298460348 "1298460348 10"
ZADD time.series 1298460358 "1298460358 11"

Your client would then need to split the values it receives from Redis in order
to get the actual value.

--

Will Maier
http://will.m.aier.us/

Reply all
Reply to author
Forward
0 new messages