All Projects → RedisJSON → Redisjson Py

RedisJSON / Redisjson Py

Licence: bsd-2-clause
An extension to redis-py for using Redis' ReJSON module

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Redisjson Py

Simple Settings
A simple way to manage your project settings.
Stars: ✭ 165 (+85.39%)
Mutual labels:  json, redis
Korio
Korio: Kotlin cORoutines I/O : Virtual File System + Async/Sync Streams + Async TCP Client/Server + WebSockets for Multiplatform Kotlin 1.3
Stars: ✭ 282 (+216.85%)
Mutual labels:  json, redis
Webdis
A Redis HTTP interface with JSON output
Stars: ✭ 2,465 (+2669.66%)
Mutual labels:  json, redis
Fastapi Plugins
FastAPI framework plugins
Stars: ✭ 104 (+16.85%)
Mutual labels:  json, redis
Apicache
Simple API-caching middleware for Express/Node.
Stars: ✭ 957 (+975.28%)
Mutual labels:  json, redis
Go Rejson
Golang client for redislabs' ReJSON module with support for multilple redis clients (redigo, go-redis)
Stars: ✭ 164 (+84.27%)
Mutual labels:  json, redis
Datoji
A tiny JSON storage service. Create, Read, Update, Delete and Search JSON data.
Stars: ✭ 222 (+149.44%)
Mutual labels:  json, redis
Bricks
A standard library for microservices.
Stars: ✭ 142 (+59.55%)
Mutual labels:  json, redis
Treefrog Framework
TreeFrog Framework : High-speed C++ MVC Framework for Web Application
Stars: ✭ 885 (+894.38%)
Mutual labels:  json, redis
Centrifuge
Real-time messaging library for Go with scalability in mind
Stars: ✭ 446 (+401.12%)
Mutual labels:  json, redis
Octosql
OctoSQL is a query tool that allows you to join, analyse and transform data from multiple databases and file formats using SQL.
Stars: ✭ 2,579 (+2797.75%)
Mutual labels:  json, redis
Zanredisdb
Yet another distributed kvstore support redis data and index. moved to: https://github.com/youzan/ZanRedisDB
Stars: ✭ 64 (-28.09%)
Mutual labels:  json, redis
Logstash Logger
Ruby logger that writes logstash events
Stars: ✭ 442 (+396.63%)
Mutual labels:  json, redis
Pantry
🥑 Free data storage as a service that allows devs to store JSON for multiple apps & users. A good resource when building personal projects, apps for hackathons, and prototypes alike.
Stars: ✭ 42 (-52.81%)
Mutual labels:  json, redis
Redisjson
RedisJSON - a JSON data type for Redis
Stars: ✭ 1,239 (+1292.13%)
Mutual labels:  json, redis
Cson
CoffeeScript-Object-Notation. Same as JSON but for CoffeeScript objects.
Stars: ✭ 1,271 (+1328.09%)
Mutual labels:  json
Spring 5 Examples
This repository is contains spring-boot 2 / spring framework 5 project examples. Using reactive programming model / paradigm and Kotlin
Stars: ✭ 87 (-2.25%)
Mutual labels:  redis
Docker Superset
Repository for Docker Image of Apache-Superset. [Docker Image: https://hub.docker.com/r/abhioncbr/docker-superset]
Stars: ✭ 86 (-3.37%)
Mutual labels:  redis
Diagram Vue
A editable SVG-based diagram component for Vue
Stars: ✭ 86 (-3.37%)
Mutual labels:  json
Supermarket
设计精良的网上商城系统,包括前端、后端、数据库、负载均衡、数据库缓存、分库分表、读写分离、全文检索、消息队列等,使用SpringCloud框架,基于Java开发。该项目可部署到服务器上,不断完善中……
Stars: ✭ 1,278 (+1335.96%)
Mutual labels:  redis

license CircleCI pypi PyVersions GitHub issues Codecov

RedisJSON Python Client

Forum Discord

rejson-py is a package that allows storing, updating and querying objects as JSON documents in a Redis database that is extended with the ReJSON module. The package extends redis-py's interface with ReJSON's API, and performs on-the-fly serialization/deserialization of objects to/from JSON.

Installation

$ pip install rejson

Usage example

   from rejson import Client, Path

   rj = Client(host='localhost', port=6379, decode_responses=True)

   # Set the key `obj` to some object
   obj = {
       'answer': 42,
       'arr': [None, True, 3.14],
       'truth': {
           'coord': 'out there'
       }
   }
   rj.jsonset('obj', Path.rootPath(), obj)

   # Get something
   print 'Is there anybody... {}?'.format(
       rj.jsonget('obj', Path('.truth.coord'))
   )

   # Delete something (or perhaps nothing), append something and pop it
   rj.jsondel('obj', Path('.arr[0]'))
   rj.jsonarrappend('obj', Path('.arr'), 'something')
   print '{} popped!'.format(rj.jsonarrpop('obj', Path('.arr')))

   # Update something else
   rj.jsonset('obj', Path('.answer'), 2.17)

   # And use just like the regular redis-py client
   jp = rj.pipeline()
   jp.set('foo', 'bar')
   jp.jsonset('baz', Path.rootPath(), 'qaz')
   jp.execute()

   # If you use non-ascii character in your JSON data, you can add the no_escape flag to JSON.GET command
   obj_non_ascii = {
     'non_ascii_string': 'hyvää'
   }
   rj.jsonset('non-ascii', Path.rootPath(), obj_non_ascii)
   print '{} is a non-ascii string'.format(rj.jsonget('non-ascii', Path('.non_ascii_string'), no_escape=True))

Encoding/Decoding

rejson-py uses Python's json. The client can be set to use custom encoders/decoders at creation, or by calling explicitly the setEncoder() and setDecoder() methods, respectively.

The following shows how to use this for a custom class that's stored as a JSON string for example:

   from json import JSONEncoder, JSONDecoder
   from rejson import Client

   class CustomClass(object):
       "Some non-JSON-serializable"
       def __init__(self, s=None):
           if s is not None:
               # deserialize the instance from the serialization
               if s.startswith('CustomClass:'):
                   ...
               else:
                   raise Exception('unknown format')
           else:
               # initialize the instance
               ...

       def __str__(self):
           _str = 'CustomClass:'
           # append the instance's state to the serialization
           ...
           return _str

       ...

   class CustomEncoder(JSONEncoder):
       "A custom encoder for the custom class"
       def default(self, obj):
           if isinstance(obj, CustomClass):
               return str(obj)
           return json.JSONEncoder.encode(self, obj)

   class TestDecoder(JSONDecoder):
       "A custom decoder for the custom class"
       def decode(self, obj):
           d = json.JSONDecoder.decode(self, obj)
           if isinstance(d, basestring) and d.startswith('CustomClass:'):
               return CustomClass(d)
           return d

   # Create a new instance of CustomClass
   obj = CustomClass()

   # Create a new client with the custom encoder and decoder
   rj = Client(encoder=CustomEncoder(), decoder=CustomDecoder())

   # Store the object
   rj.jsonset('custom', Path.rootPath(), obj))

   # Retrieve it
   obj = rj.jsonget('custom', Path.rootPath())

API

As rejson-py exposes the same methods as redis-py, it can be used as a drop-in replacement. On top of Redis' core commands, the client also adds ReJSON's vocabulary and a couple of helper methods. These are documented in the API.md file, which can be generated by running:

$ python gendoc rejson > API.md

For complete documentation about ReJSON's commands, refer to ReJSON's website.

License

BSD 2-Clause

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].