Is it possible to convert a SET to a ZSET

496 views
Skip to first unread message

eugene miretsky

unread,
Dec 14, 2012, 12:34:20 PM12/14/12
to redi...@googlegroups.com
Hi,

Is it possible to convert a SET to a ZSET? 

It seems like a relatively common use case where there is a set with elements that have a score, that can also be used for simple set operations that don't need the score info. 
For example: A sorted set of friends where the score is "how close" they are to the user. The same set can be used to find out things like "Is user X friends with user Y?", or to find the mutual friends of 2 users. In the latter case, one would intersect the 2 sorted sets to find mutual friends, the result will be a sorted set where the score is some sort of combined friendship factor. If all I'm looking for is a set of mutual friends, there is really  no reason to waste memory and processing power(or sorting) .

Thanks!

Josiah Carlson

unread,
Dec 14, 2012, 1:48:10 PM12/14/12
to redi...@googlegroups.com
On Fri, Dec 14, 2012 at 9:34 AM, eugene miretsky
<eugene....@gmail.com> wrote:
> Hi,
>
> Is it possible to convert a SET to a ZSET?

Yes.

ZINTERSTORE zset-copy 1 set-original

> It seems like a relatively common use case where there is a set with
> elements that have a score, that can also be used for simple set operations
> that don't need the score info.

Based on your description, what you really want is to convert a ZSET
to a SET. That is not supported.

Regards,
- Josiah
Reply all
Reply to author
Forward
0 new messages