Skip to main content

For using redis more easily.

Project description

k3redisutil

Action-CI Build Status 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 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.0.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

k3redisutil-0.1.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file k3redisutil-0.1.0.tar.gz.

File metadata

  • Download URL: k3redisutil-0.1.0.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for k3redisutil-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e009921d3ac3220b938d455fb52466b222e3fe89419da7c796b9dc77d3050a45
MD5 0a2c53ca6983f8bd75fe1c7c126293bc
BLAKE2b-256 67cad59ab5ef8b0115e94388effb085b392d35ddffdcc92c66af2f13457fed70

See more details on using hashes here.

File details

Details for the file k3redisutil-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: k3redisutil-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for k3redisutil-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c73923f5c49ee0391e2a4b16646900ac118e6bbfcdd961170f820c8cb6a79161
MD5 23534127863bbacdd887ff55dbd6a5b3
BLAKE2b-256 af32ddeec33ad29fea89d9693dfaae1cc1798a2c31b9059c57d5d63dd077a42b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page