redis-cooker
An redis python datastructures package
Installation
To install redis-cooker, simply:
$ pip install redis-cooker
or from source:
$ python setup.py install
Getting Started
>>> from redis_cooker.clients import set_connection_url
>>> from redis_cooker.collections import RedisList
>>>
>>> set_connection_url('redis://:@127.0.0.1:6379/15')
>>> for i in RedisList("Testing:RedisList", init=['Hello', 'World']):
>>> print(i)
Hello
World
By default, all data will use the built-in json serializer.
Attention!
- If the key has existed in Redis, new object will connect to the existed key and ignore the "init" value.
- For complex operations, redis-cooker uses lua instead of python.
Datastructures
redis-cooker provide 6 datastructures in current version:
- collections: RedisMutableSet, RedisString, RedisList, RedisDict, RedisDeque, RedisDefaultDict
- others: ABNTest
Integration with Pydantic
>>> from typing import List
>>>
>>> from pydantic import BaseModel
>>> from redis_cooker.clients import set_connection_url
>>> from redis_cooker.collections import RedisList
>>>
>>> set_connection_url('redis://:@127.0.0.1:6379/15')
>>>
>>>
>>> class Person(BaseModel):
name: str
age: int
>>>
>>>
>>> data = [{"name": "A", "age": 15},{"name": "B", "age": "16"}]
>>> for i in RedisList("Testing:Pydantic", init=data, schema=Person):
>>> print(i)
{'name': 'A', 'age': 15}
{'name': 'B', 'age': '16'}
Integration with DRF Serializer
>>> from typing import List
>>>
>>> from rest_framework import serializers
>>> from redis_cooker.clients import set_connection_url
>>> from redis_cooker.collections import RedisList
>>>
>>> set_connection_url('redis://:@127.0.0.1:6379/15')
>>>
>>>
>>> class DRFPerson(serializers.Serializer):
name = serializers.CharField()
age = serializers.IntegerField()
>>>
>>>
>>> data = [{"name": "A", "age": 15},{"name": "B", "age": "16"}]
>>> for i in RedisList("Testing:DRF", init=data, schema=DRFPerson):
>>> print(i)
OrderedDict([('name', 'A'), ('age', 15)])
OrderedDict([('name', 'B'), ('age', 16)])
Use ABNTest in your internal A/B Test
>>> from redis_cooker.abn_test import ABNTest, Choice
>>> from redis_cooker.clients import current_redis_client, set_connection_url
>>>
>>> set_connection_url('redis://:@127.0.0.1:6379/15')
>>> client = current_redis_client()
>>>
>>> topic = "lead comment"
>>> choices = [Choice(name="A", value=5), Choice(name="B", value=5), Choice(name="C", value=2)]
>>> abn_test = ABNTest(topic, choices)
>>> choice = abn_test.fetch()
Metadata
Release files for redis-cooker 2020.12.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| redis-cooker-2020.12.1.tar.gz | 11.4 kB | Without provenance | Details for redis-cooker-2020.12.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| redis_cooker-2020.12.1-py3-none-any.whl | Python 3 | none | any | Details for redis_cooker-2020.12.1-py3-none-any.whl |
Total release size: 26.1 kB
Release files / redis-cooker-2020.12.1.tar.gz
| Download URL | redis-cooker-2020.12.1.tar.gz |
|---|---|
| Size | 11.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
23c1cab5dfb236d25012aa6ba14832730571c268f22ff54f79514fbc664998c5
|
|
BLAKE2b-256 checksum How to use checksums |
acc59c603ad781b9f6d82ff4ac183f0a3f6295053ac07b8b5b18034134ede065
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.6.12
|
Release files / redis_cooker-2020.12.1-py3-none-any.whl
| Download URL | redis_cooker-2020.12.1-py3-none-any.whl |
|---|---|
| Size | 14.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f3c4b1ae805bce65eff527bbc2a5ab365ef59ba197d4bae405f033c3ab5c1915
|
|
BLAKE2b-256 checksum How to use checksums |
45eaaa8d3c5af1dabb479985c90c49f304a3392389e57a60abca06761c36a58f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.6.12
|
Security for redis-cooker 2020.12.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.