File: string_set_get.py

package info (click to toggle)
python-redis 6.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,432 kB
  • sloc: python: 60,318; sh: 179; makefile: 128
file content (25 lines) | stat: -rw-r--r-- 474 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# EXAMPLE: set_and_get
# HIDE_START
"""
Code samples for data structure store quickstart pages:
    https://redis.io/docs/latest/develop/get-started/data-store/
"""

import redis

r = redis.Redis(host="localhost", port=6379, db=0, decode_responses=True)
# HIDE_END

res = r.set("bike:1", "Process 134")
print(res)
# >>> True
# REMOVE_START
assert res
# REMOVE_END

res = r.get("bike:1")
print(res)
# >>> "Process 134"
# REMOVE_START
assert res == "Process 134"
# REMOVE_END