Created
August 26, 2014 15:32
-
-
Save elliottcordo/f3d114b3d2863a5ab29a to your computer and use it in GitHub Desktop.
Intro to Redis
This file contains 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
127.0.0.1:6379> sadd rl1 matt | |
127.0.0.1:6379> sadd rl1 ben | |
127.0.0.1:6379> sadd rl1 judy | |
127.0.0.1:6379> smembers rl1 | |
1) "judy" | |
2) "ben" | |
3) "matt" | |
127.0.0.1:6379> sadd rl2 matt | |
127.0.0.1:6379> sadd rl2 jim | |
127.0.0.1:6379> sadd rl2 kyle | |
127.0.0.1:6379> sadd rl2 judy | |
127.0.0.1:6379> smembers rl2 | |
1) "jim" | |
2) "judy" | |
3) "kyle" | |
Union (& store) the two sets | |
127.0.0.1:6379> sunionstore trl3 rl1 rl2 | |
(integer) 5 | |
127.0.0.1:6379> smembers trl3 | |
1) "matt" | |
2) "ben" | |
3) "judy" | |
4) "kyle" | |
5) "jim" | |
Intersect (& store) the two sets | |
127.0.0.1:6379> sinterstore trl4 rl1 rl2 | |
(integer) 2 | |
127.0.0.1:6379> smembers trl4 | |
1) "judy" | |
2) "matt" | |
Create a zset (score member) | |
127.0.0.1:6379> zadd rlw 10 matt | |
(integer) 1 | |
127.0.0.1:6379> zadd rlw 20 ben | |
(integer) 1 | |
127.0.0.1:6379> zadd rlw 30 judy | |
(integer) 1 | |
127.0.0.1:6379> zadd rlw 40 kyle | |
(integer) 1 | |
127.0.0.1:6379> zadd rlw 50 jim | |
(integer) 1 | |
127.0.0.1:6379> zrange rlw 0 -1 | |
1) "matt" | |
2) "ben" | |
3) "judy" | |
4) "kyle" | |
5) "jim" | |
127.0.0.1:6379> zrange rlw 0 -1 WITHSCORES | |
1) "matt" | |
2) "10" | |
3) "ben" | |
4) "20" | |
5) "judy" | |
6) "30" | |
7) "kyle" | |
8) "40" | |
9) "jim" | |
127.0.0.1:6379> zrange r2 0 -1 | |
1) "matt" | |
2) "judy" | |
127.0.0.1:6379> zrange r2 0 -1 WITHSCORES | |
1) "matt" | |
2) "11" | |
3) "judy" | |
4) "31" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment