k3redisutil
For using redis more easily.
k3redisutil is a component of pykit3 project: a python3 toolkit set.
For using redis more easily.
Install
pip install k3redisutil
Synopsis
import time
import k3redisutil
# Using redis as a duplex cross process communication channel pool.
# client and server with the same channel name "/foo" is a pair
c = k3redisutil.RedisChannel(6379, "/foo", "client")
s = k3redisutil.RedisChannel(6379, "/foo", "server")
c.send_msg("c2s")
s.send_msg("s2c")
# list channels
print(c.list_channel("/")) # ["/foo"]
print(s.recv_msg()) # c2s
print(c.recv_msg()) # s2c
cli = k3redisutil.RedisProxyClient([("127.0.0.1", 2222), ("192.168.0.100", 222)])
cli.set("k1", "v1", retry=1)
cli.set("k2", "v2", expire=1000) # msec
print(cli.get("k1", retry=2))
# out: 'v1'
print(cli.get("k2"))
# out: 'v2'
time.sleep(1)
cli.get("k2")
# raise a 'redisutil.KeyNotFoundError' because it is timeout
cli.hset("hashname1", "k3", "v3")
cli.hset("hashname2", "k4", "v4", expire=1000)
print(cli.hget("hashname1", "k3"))
# out: 'v3'
print(cli.hget("hashname2", "k4"))
# out: 'v4'
time.sleep(1)
cli.hget("hashname2", "k4")
# raise a 'redisutil.KeyNotFoundError' because it is timeout
Author
Zhang Yanpo (张炎泼) drdr.xp@gmail.com
Copyright and License
The MIT License (MIT)
Copyright (c) 2015 Zhang Yanpo (张炎泼) drdr.xp@gmail.com
Metadata
Release files for k3redisutil 0.1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| k3redisutil-0.1.8.tar.gz | 11.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| k3redisutil-0.1.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.7 kB
Release files / k3redisutil-0.1.8.tar.gz
| Download URL | k3redisutil-0.1.8.tar.gz |
|---|---|
| Size | 11.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dce71b2e2052b42b4a8523482d5af63911b2fbedd5001705216e75c7ea7850a2
|
|
BLAKE2b-256 checksum How to use checksums |
00827f783dc5412c1c06eb8d014c62cc0bb5ef51e7093a3e87763ba2a5356ebc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Release files / k3redisutil-0.1.8-py3-none-any.whl
| Download URL | k3redisutil-0.1.8-py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
212a43f87a1f1afdee1d84ed2f32b0f492e410087e3df9c557353469b17b3424
|
|
BLAKE2b-256 checksum How to use checksums |
e2460ca832f73dd075a1c2bb4a0d2875573e0a190457f1fb1a6eee7087b95a91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|