Skip to main content

k3redisutil

Action-CI Documentation Status Package

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.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for k3redisutil 0.1.9
File Size Uploaded
k3redisutil-0.1.9.tar.gz 12.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for k3redisutil 0.1.9
File Interpreter ABI Platform
k3redisutil-0.1.9-py3-none-any.whl Python 3 none any Details

Total release size: 22.9 kB

Release files / k3redisutil-0.1.9.tar.gz

Download URL k3redisutil-0.1.9.tar.gz
Size 12.6 kB
Tags Source
SHA-256 checksum
How to use checksums
54d446f39ba613741a8cf076b3307e3bb35643db7357acfaf73fb6ccd670ccae
BLAKE2b-256 checksum
How to use checksums
f4892684a38c05cb0e2201e2260143b6d0a26d5b576b1fb8cebf9c1206365c70
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.9-py3-none-any.whl

Download URL k3redisutil-0.1.9-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8b57120b3068922ba79a6a1eb376a949f92507689d9b1c9e62ecc998331d30e6
BLAKE2b-256 checksum
How to use checksums
ddde9cfa73591ed3493bef4917a9c550ca46ac4846d2c611e77516d35c6617d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release history Release notifications | RSS feed

This release

0.1.9 This release

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page