Skip to main content

Simple redis-py wrapper library

Project description

Simple redis-py wrapper library

Installation

To install gxredis, simply:

$ sudo pip install gxredis

Usage

>>> import redis
>>> from gxredis import *

>>> class ItemDao(RedisDao):
>>>        item = RedisString("device:{device_id}:item:{item_id}")
>>>        item_list = RedisList("device:{device_id}:list")
>>>        item_set = RedisSet("device:{device_id}:set")
>>>        item_hash = RedisHash("device:{device_id}:hash")
>>>        item_zset = RedisSortedSet("device:{device_id}:zset")

>>> client = redis.StrictRedis("localhost", 6379, 15)
>>> dao = ItemDao(client, key_params={"device_id": "GX123"})

>>> dao.item
RedisString(key="device:{device_id}:item:{item_id}", key_params={'device_id': 'GX123'})

>>> dao.item_list
RedisList(key="device:{device_id}:list", key_params={'device_id': 'GX123'})

>>> dao.item(item_id=1).set("item01")
True

>>> dao.item(item_id=1).get()
'item01'

>>> pipe = dao.pipeline()
>>> accr1 = pipe.item(item_id=1)     # accessor for item01
>>> accr2 = pipe.item(item_id=2)     # accessor for item02
>>> accr1.set("item01")
>>> accr2.set("item02")
>>> pipe.item_list.rpush(accr1.key)
>>> pipe.item_list.rpush(accr2.key)
>>> pipe.execute()

>>> dao.item_list.lrange(0, 100)
['device:GX123:item:1', 'device:GX123:item:2']

LICENSE

  • MIT

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

gxredis-0.3.2.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gxredis-0.3.2-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file gxredis-0.3.2.tar.gz.

File metadata

  • Download URL: gxredis-0.3.2.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.2

File hashes

Hashes for gxredis-0.3.2.tar.gz
Algorithm Hash digest
SHA256 ea3f686a22e9371a2103bef202d4513c388ac36d0df5d0212ffc218c41532502
MD5 2ec1c4e28959f22c78ae3fd62ddffead
BLAKE2b-256 ab6d9583913fa43ff5de52bf8c0417f96e4db0c68cffbed4465276557f6962b6

See more details on using hashes here.

File details

Details for the file gxredis-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: gxredis-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.2

File hashes

Hashes for gxredis-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 32dc38cf9a3065e3d3b75f0cd1ca1fea083a554a119c3bc716b33aa54d33ae64
MD5 a46939adcec004fba4c0e8fa799aa98e
BLAKE2b-256 91ba0aa30938d3d140600b7c07486ea3e73e08841a782d4450ad5067b092d75d

See more details on using hashes here.

Supported by

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