Skip to content

Commit 5d275f7

Browse files
committed
sortedSet
init
1 parent c0508a8 commit 5d275f7

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Chapter2/sortedSet.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import redis
2+
3+
r = redis.Redis(host='127.0.0.1',
4+
port=6379,
5+
db=0,
6+
decode_responses=True)
7+
8+
'''
9+
A sorted set is different from set because of an associated score
10+
and well.., its sorted
11+
-> Not as fast as sets as scores are compared
12+
-> speed of ops is O(Log(N)), where N is elements in set
13+
-> implemented as two lists
14+
a) skip list with hash table
15+
b) Zip list
16+
'''
17+
18+
r.zadd(name='Rajeev', mapping={'age': 23,
19+
'occupation': 25})
20+
21+
resp = r.zrevrange("Rajeev", start=0, end=-1, withscores=True)
22+
print(resp)

0 commit comments

Comments
 (0)