Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

SmartNinja Redis - a wrapper that simulates Redis on localhost and uses real Redis in production.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for smartninja-redis, version 0.3
Filename, size File type Python version Upload date Hashes
Filename, size smartninja-redis-0.3.tar.gz (2.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page