Redis utilities for easier client management and proxy support
Project description
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 k3redisutil
import time
# 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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
k3redisutil-0.1.3.tar.gz
(11.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file k3redisutil-0.1.3.tar.gz.
File metadata
- Download URL: k3redisutil-0.1.3.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c545e0d9c12af4f51252b135aceaab98dd48dc53021c1c4517c5b05977e68519
|
|
| MD5 |
eb998083fa3443f56ca038432db36193
|
|
| BLAKE2b-256 |
b9342b03effbd80ad49ce100ae9382f74481fec3be3e7562237e06272f00441f
|
File details
Details for the file k3redisutil-0.1.3-py3-none-any.whl.
File metadata
- Download URL: k3redisutil-0.1.3-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a4e623232589629f3b376fa4e9892e981b3f0d8a3f1a6521ef0a061bace05b9
|
|
| MD5 |
0ec8459c1ffa822be5c73f26d9c97f7a
|
|
| BLAKE2b-256 |
a1d5745a6f1041cba3c054297715137c64323a38cf7f3e9b86202e13b08137cd
|