Skip to content

Commit ddae7d4

Browse files
committed
String multiget and set
Set using a dict and get returns a list
1 parent 569bbe1 commit ddae7d4

File tree

3 files changed

+11
-31
lines changed

3 files changed

+11
-31
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
dump.rdb

stringExamples.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,16 @@
66
encoding=u'utf-8',
77
decode_responses=True)
88

9-
# Multi-SET of keys
10-
r.mset('first', "First Key Value", 'second', "Second key Value")
9+
# Multi-SET of keys: use dict for all these
10+
r.mset({'first': 'FirstKeyValue', 'second': 'SecondkeyValue'})
1111

1212
# Multi-Get
13-
response = r.mget('first', 'second')
13+
response = r.mget(*('first', 'second'))
14+
print("MSET & MGET: ", end="")
1415
print(response)
1516

17+
18+
# set so that it expires after 10 seconds
19+
r.setex(name="ExpireKey", time=10, value="Boom!!!")
20+
21+
r.set(name="key", value="hello", ex=5, px=None, nx=True, xx=False)

stringExamples[NotWorking].py

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)