SmartNinja Redis
A wrapper that simulates Redis on localhost (using TinyDB) and uses a real Redis db in production.
Important: This package is meant to be used at SmartNinja courses for learning purposes. It is not advised to use this package for serious projects. Use the default redis package instead. You only need to change the import statement.
Installation
Install via pip:
pip install smartninja-redis
Dependencies
The package has two dependencies: tinydb and redis. It installs them automatically.
Usage
Access Redis via the from_url() function:
import smartninja_redis as redis
r_url = redis.from_url(url="localhost")
r_url.set(name="Ninja", value="Smart")
print(r_url.get("Ninja"))
or via Redis class directly:
from smartninja_redis import Redis
r_class = Redis(host="localhost")
r_class.set(name="smart", value="ninja")
print(r_class.get("smart"))
For now, only set() and get() methods work on localhost.
The following set() parameters do not work: ex, px, nx, xx
TinyDB
TinyDB is used to simulate Redis on localhost (if you don't have Redis installed and REDIS_URL env var set). TinyDB does not store any data on disk (in this case). It uses memory storage only.
Using a real Redis service
If you'd like to use SmartNinja with a real Redis service (instead of TinyDB), make sure you have REDIS_URL environment variable set.
Contributions
Contributions via pull requests are warmly welcome!
TODO
- tests
- CI
Release files for smartninja-redis 0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| smartninja-redis-0.3.tar.gz | 2.5 kB | Details |
Release files / smartninja-redis-0.3.tar.gz
| Download URL | smartninja-redis-0.3.tar.gz |
|---|---|
| Size | 2.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
236123f0bc3991491a5c08e4ec233f1164f5271860a56c1d047cf2b16ad31e2e
|
|
BLAKE2b-256 checksum How to use checksums |
423dbe46a45d885ab6c1b3e63d40970b02d7fdc6d5f1d6ea631b93899b5cd5bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1
|