Skip to main content

Pythonic Redis Client.

Project description

**Redisworks 0.2.7**

**The Pythonic Redis Client**

Why Redisworks?

- Lazy Redis Queries
- Dynamic Typing
- Ease of use

Have you ever used PyRedis and wondered why you have to think about types all the time? That you have to constantly convert objects to strings and back and forth since Redis keeps most things as strings?

That's why I wrote Redisworks. Redis works provides a Pythonic interface to Redis. Let Redisworks take care of type conversions for you.

Behind the scene, Redisworks uses [DotObject]( to provide beautiful dot notation objects and lazy Redis queries.


let's say if you want all the keys in Redis to start with the word `root`.
Then you:

>>> root = Root() # connects to Redis on local host by default

Or if you want to be more specific:

>>> root = Root(host='localhost', port=6379, db=0)

**Saving to Redis**

Saving to Redis is as simple as assigning objects to attributes of root or attributes of attributes of root (you can go as deep as you want.)
Make sure you are not using any Python's reserved words in the key's name.

Save to Redis
>>> from redisworks import Root
>>> import datetime
>>> root = Root()
>>> = [1, 3, 4]
>>> some_date = datetime.datetime(2016, 8, 22, 10, 3, 19)
>>> root.time = some_date
>>> root.the.mapping.example = {1:1, "a": "b"}

Redis works will automatically convert your object to the proper Redis type and immediately write it to Redis as soon as you assign an element!

The respective keys for the above items will be just like what you type: ``, `root.time`, `root.the.mapping.example`:

In the redis-cli client:

Redis-cli> scan 0
1) "0"
2) 1) "root.the.mapping.example"
2) "root.time"
3) ""> type root.the.mapping.example
hash> type root.time
string> type

**Reading from Redis**

Redis works returns Lazy queries just like how Django returns lazy queries. In fact the lazy objects code is borrowed from Django!

If you ran the example from [Saving to Redis](#saving-to-redis), run a flush `root.flush()` to empty Redisworks Cache. This is so it goes and gets the objects from Redis instead of reading its own current copy of data:

Read from Redis
>>> from redisworks import Root
>>> import datetime
>>> root = Root()
>>> thetime = root.time
>>> thelist =
>>> mydict = root.the.mapping.example
>>> mydict # is not evalurated yet!
<Lazy object: root.the.mapping.example>
>>> print(mydict)
{1: 1, 'a': 'b'} # Now all the 3 objects are read from Redis!
>>> mydict
{1: 1, 'a': 'b'}
[1, 3, 4]
>>> root.time
2016-08-22 10:03:19

**Other examples**

Take a look at [](

**Primary Author**
Sep Dehpour


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for redisworks, version 0.2.7
Filename, size File type Python version Upload date Hashes
Filename, size redisworks-0.2.7-py2-none-any.whl (7.6 kB) File type Wheel Python version py2 Upload date Hashes View hashes
Filename, size redisworks-0.2.7-py3-none-any.whl (7.6 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size redisworks-0.2.7.tar.gz (5.1 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page