Skip to content

Implements a wrapper for Redis datatypes so they mimic the datatypes found in Python.

Notifications You must be signed in to change notification settings

livni/redis_wrap

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Python wrapper for Redis datatypes

Implements a wrapper for Redis datatypes so they mimic the datatypes found in Python.

Requires Redis 2.0+ and newest version of redis-py.

For best performance the wrappers are lazy and use direct Redis calls, for example:

len(get_list("bears")) # will call redis_client.llen("bears")

'grizzly' in get_hash('bears') # will call redis_client.hexists('bears', 'grizzly')

redis-py can be downloaded from here:

You can also quick install it from PyPi:

  • $ sudo easy_install redis_wrap

Related:

Examples

Example of list wrapper:

bears = get_list('bears')
bears.append('grizzly')
assert len(bears) == 1
assert 'grizzly' in bears

Example of hash wrapper:

villains = get_hash('villains')
assert 'riddler' not in villains

villains['riddler'] = 'Edward Nigma'
assert 'riddler' in villains

assert len(villains.keys()) == 1

del villains['riddler']
assert len(villains) == 0

Example of set wrapper:

fishes = get_set('fishes')
assert 'nemo' not in fishes

fishes.add('nemo')
assert 'nemo' in fishes

for item in fishes:
    assert item == 'nemo'

Example of other redis connection::

setup_system('other', host='127.0.0.1', port=6379)
bears = get_list('bears', 'other')

About

Implements a wrapper for Redis datatypes so they mimic the datatypes found in Python.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%