All Projects → seperman → Redisworks

seperman / Redisworks

Licence: other
Pythonic Redis Client

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Redisworks

Quick redis blog
QuickRedis is a free forever Redis Desktop manager. It supports direct connection, sentinel, and cluster mode, supports multiple languages, supports hundreds of millions of keys, and has an amazing UI. Supports both Windows, Mac OS X and Linux platform.
Stars: ✭ 594 (+661.54%)
Mutual labels:  redis, redis-client
Hslcommunication
An industrial IoT underlying architecture framework, focusing on the underlying technical communications and cross-platform, cross-language communication functions, to achieve a variety of mainstream PLC data reading and writing, to achieve modbus of various protocols read and write, and so on, to support the rapid construction of industrial upper computer software, configuration software, SCADA software, factory mes system, To help enterprise Industry 4.0 take-off, to achieve intelligent manufacturing, smart factory goals. The main PLC contains Siemens, Mitsubishi, Omron, Panasonic, Modbus, AB-PLC, Redis
Stars: ✭ 816 (+946.15%)
Mutual labels:  redis, redis-client
Redis Operator
Redis Operator creates/configures/manages high availability redis with sentinel automatic failover atop Kubernetes.
Stars: ✭ 658 (+743.59%)
Mutual labels:  redis, redis-client
Redis
Vapor provider for RediStack
Stars: ✭ 434 (+456.41%)
Mutual labels:  redis, redis-client
Cpp redis
C++11 Lightweight Redis client: async, thread-safe, no dependency, pipelining, multi-platform - NO LONGER MAINTAINED - Please check https://github.com/cpp-redis/cpp_redis
Stars: ✭ 855 (+996.15%)
Mutual labels:  redis, redis-client
Redis Admin
redis client tool,redis web client,redis web ui,spring-boot support
Stars: ✭ 436 (+458.97%)
Mutual labels:  redis, redis-client
Redis Tui
A Redis Text-based UI client in CLI
Stars: ✭ 757 (+870.51%)
Mutual labels:  redis, redis-client
Redis
Redis commands for Elixir
Stars: ✭ 357 (+357.69%)
Mutual labels:  redis, redis-client
Perfect Redis
A Swift client for Redis.
Stars: ✭ 26 (-66.67%)
Mutual labels:  redis, redis-client
Redis Py Cluster
Python cluster client for the official redis cluster. Redis 3.0+.
Stars: ✭ 934 (+1097.44%)
Mutual labels:  redis, redis-client
Redis Plus Plus
Redis client written in C++
Stars: ✭ 428 (+448.72%)
Mutual labels:  redis, redis-client
Goredis
redis client for golang
Stars: ✭ 59 (-24.36%)
Mutual labels:  redis, redis-client
Stackexchange.redis.extensions
Stars: ✭ 419 (+437.18%)
Mutual labels:  redis, redis-client
Stackexchange.redis
General purpose redis client
Stars: ✭ 4,986 (+6292.31%)
Mutual labels:  redis, redis-client
Lettuce Core
Advanced Java Redis client for thread-safe sync, async, and reactive usage. Supports Cluster, Sentinel, Pipelining, and codecs.
Stars: ✭ 4,319 (+5437.18%)
Mutual labels:  redis, redis-client
Iodine
iodine - HTTP / WebSockets Server for Ruby with Pub/Sub support
Stars: ✭ 720 (+823.08%)
Mutual labels:  redis, redis-client
Fastoredis
FastoRedis is a crossplatform Redis GUI management tool.
Stars: ✭ 316 (+305.13%)
Mutual labels:  redis, redis-client
Crystal Redis
Full featured Redis client for Crystal
Stars: ✭ 345 (+342.31%)
Mutual labels:  redis, redis-client
Redix
Fast, pipelined, resilient Redis driver for Elixir. 🛍
Stars: ✭ 816 (+946.15%)
Mutual labels:  redis, redis-client
Php Redis Implementation
Raw wrapper for real Redis fans.
Stars: ✭ 48 (-38.46%)
Mutual labels:  redis, redis-client

Redisworks 0.3.0

Python Versions License Build Status Coverage Status

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?

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.

Install

pip install redisworks

Note that RedisWorks needs Redis server 2.4+.

Setup

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)

password

Any other parameter that you pass to Root will be passed down to PyRedis. For example:

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

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.

Example:

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

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:

If you use redis-cli, you will notice that the data is saved in the proper Redis data type:

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

Reading the data is as simple as if it was just saved in Python memory!

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, 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:

>>> from redisworks import Root
>>> 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": 10}}  # Now all the 3 objects are read from Redis!
>>> mydict
{1:1, "a": {"b": 10}}
>>> root.my.list
[1, 3, 4]
>>> root.my.other.list
[1, [2, 2]]
>>> root.time
2016-08-22 10:03:19

Changing root key name

Every key name by default starts with the word root. If you want to use another name, simple subclass Root:

>>> from redisworks import Root
>>> class Post(Root):
...     pass
>>> post=Post()
>>> post.item1 = "something"  # saves to Redis
...
>>> print(post.item1)  # loads from Redis
something

Numbers as attribute names

Let's say you want root.1 as a key name. Python does not allow attribute names start with numbers.

All you need to do is start the number with the character i so Redisworks takes care of it for you:

>>> root.i1 = 10
>>> print(root.i1)
10

The actual key in Redis will be root.1

Dynamic key names

>>> path1 = 'blah'
>>> path2 = 'blah.here`'

>>> root[path1] = 'foo'
>>> root[path2] = 'foo bar'

>>> root.blah
foo
>>> root.blah.here
foo bar

Other examples

Take a look at example.py

Primary Author

Seperman (Sep Dehpour)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].