Created
April 25, 2012 02:04
-
-
Save ntulip/2485517 to your computer and use it in GitHub Desktop.
redis_sets.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How beautiful and simple it is to store relationships in redis | |
# Think - I have 4 friends, you have 4 friends, but how many friends | |
# do we have in common? And did I tell you it handles sorted sets? | |
# Sorted sets are like sets but with a score. The score provides sorting | |
# and ranking capabilities | |
redis 127.0.0.1:6379> sadd friends:leto ghanima paul chani jessica | |
(integer) 4 | |
redis 127.0.0.1:6379> sadd friends:duncan paul jessica alia | |
(integer) 3 | |
redis 127.0.0.1:6379> sismember friends:leto jessica | |
(integer) 1 | |
redis 127.0.0.1:6379> sismember friends:leto vladimir | |
(integer) 0 | |
redis 127.0.0.1:6379> sinter friends:leto friends:duncan | |
1) "jessica" | |
2) "paul" | |
redis 127.0.0.1:6379> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment