Skip to main content

A library to make sharing the same redis connection easier

Project description

NamedRedis by Ouroboros Coding

pypi version MIT License

Named Redis: a simple wrapper for redis using config-oc to act as a factory for named connections

Install

pip install namedredis

Requires

namedredis requires python 3.10 or higher

Uses

namedredis uses the redis package and returns an instance of StrictRedis.

Using

example.py

from nredis import nr, reset

# Reference every time
nr('main').set('foo', 'bar')

# Store instance for multiple uses
main_redis = nr('main')
main_redis.set('hello', 'world!')

# Re-fetches a config and resets the connection
reset('main')

# Resets all open connections
reset()

config.json

{
	"redis": {
		"main": {
			"host": "localhost",
			"port": 6379,
			"db": 0,
			"protocol": 3
		},
		"secondary": {
			"db": 1
		}
	}
}

Options

The following options all have defaults and don't necessarily need to be set. For more non-standard options, see redis.StrictRedis

Name Type Default Description
host str "localhost" The IP or host name of the server
port unsigned 6379 The port of the server
db unsigned 0 The DB to connect to on the server
protocol unsigned 3 The protocol version to use

Project details


Download files

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

Source Distribution

namedredis-1.0.2.tar.gz (3.9 kB view details)

Uploaded Source

File details

Details for the file namedredis-1.0.2.tar.gz.

File metadata

  • Download URL: namedredis-1.0.2.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.31.0 rfc3986/1.5.0 tqdm/4.65.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for namedredis-1.0.2.tar.gz
Algorithm Hash digest
SHA256 5d1a451e3731cfe26a8b714dbf14641306c5501f4d7fd4d0736ae3e38ee89aa6
MD5 9985ce6f2c45c46944e38ca8500f0ea3
BLAKE2b-256 e1dc1b9e468f68a52ad8d5d46efb7fd9c5dd892d2f1f8e73b2d10cb0f55fdd6b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page