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](https://github.com/seperman/dotobject) to provide beautiful dot notation objects and lazy Redis queries.

**Setup**

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

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


Or if you want to be more specific:

setup
>>> 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()
>>> root.my.list = [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.my.list`, `root.time`, `root.the.mapping.example`:

In the redis-cli client:

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

**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 = root.my.list
>>> 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'}
>>> root.my.list
[1, 3, 4]
>>> root.time
2016-08-22 10:03:19

**Other examples**

Take a look at [example.py](example.py)

**Primary Author**
Sep Dehpour

Github: https://github.com/seperman
Linkedin: http://www.linkedin.com/in/sepehr
ZepWorks: http://www.zepworks.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

redisworks-0.2.7.tar.gz (5.1 kB view details)

Uploaded Source

Built Distributions

redisworks-0.2.7-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

redisworks-0.2.7-py2-none-any.whl (7.6 kB view details)

Uploaded Python 2

File details

Details for the file redisworks-0.2.7.tar.gz.

File metadata

  • Download URL: redisworks-0.2.7.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for redisworks-0.2.7.tar.gz
Algorithm Hash digest
SHA256 ccbc6ec676c4cfe3bd716be59f0b9b13bb7aa1dd021e636273ac453b96a3b165
MD5 6ba8380258ed84a8a1842a9d3331edf4
BLAKE2b-256 898ac7c8cf776a647e53f63341abb7890ef7cdf90a80eee71e021668b3af0912

See more details on using hashes here.

File details

Details for the file redisworks-0.2.7-py3-none-any.whl.

File metadata

File hashes

Hashes for redisworks-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 a696a0a899a3b05c58694f394f0557f3c281c6be15cf20bb1af227cbaf655404
MD5 7372086ad8122e1e408f4167265c9553
BLAKE2b-256 6f1424e57fbd0804fe785c34cf03104b84da390e913fb9b731bafb8f30b64e78

See more details on using hashes here.

File details

Details for the file redisworks-0.2.7-py2-none-any.whl.

File metadata

File hashes

Hashes for redisworks-0.2.7-py2-none-any.whl
Algorithm Hash digest
SHA256 c5efbdaeadb9258447cc7568d25dfa7a6097aa9ff4237a42aa7cdbfabffd214b
MD5 7d7db1de2ad40f184d08d865c89c86d7
BLAKE2b-256 fb75640e1c3da99f1e05912b2c5d0a2637e1c039e4e7ee765d0bbb45a2fab308

See more details on using hashes here.

Supported by

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