Skip to main content

Redis built into a python package

Project description

Redislite

CI/CD Build Status Codestyle Coverage Current Version Supported Python License Documentation

Description

Redislite is a self contained Python interface to the Redis key-value store.

It provides enhanced versions of the Redis-Py Python bindings for Redis. That provide the following added functionality:

  • Easy to use - It provides a built in Redis server that is automatically installed, configured and managed when the Redis bindings are used.
  • Flexible - Create a single server shared by multiple programs or multiple independent servers. All the servers provided by Redislite support all Redis functionality including advanced features such as replication and clustering.
  • Compatible - It provides enhanced versions of the Redis-Py python Redis bindings as well as functions to patch them to allow most existing code that uses them to run with little or no modifications.
  • Secure - It uses a secure default Redis configuraton that is only accessible by the creating user on the computer system it is run on.

Requirements

The redislite module requires Python 3.6 or higher.

Installing requirements on Linux

Make sure Python development headers are available when installing redislite.

On Ubuntu/Debian systems, install them with:

apt-get install python-dev

On Redhat/Fedora systems, install them with:

yum install python-devel

Installing requirements on Mac OSX

Redislite for OSX comes as a wheel package by default that can be installed using current versions of pip.

To install Redislite on MacOSX using the sdist package instead you will need the XCode command line utilities installed. If you do not have xcode installed on recent OSX releases they can be installed by running:

xcode-select --install

Installing requirements on Microsoft Windows

Redislite can be installed on newer releases of Windows 10 under the Bash on Ubuntu shell.

Install it using the instructions at https://msdn.microsoft.com/commandline/wsl/install_guide

Then start the bash shell and install the python-dev package as follows:

apt-get install python-dev

Installation

To install redislite, simply:

$ pip install redislite

or from source:

$ python setup.py install

Getting Started

redislite provides enhanced versions of the redis-py redis.Redis() and redis.StrictRedis() classes that take the same arguments as the corresponding redis classes and take one additional optional argument. Which is the name of the Redis rdb file to use. If the argument is not provided it will create set up a new redis server.

redislite also provides functions to MonkeyPatch the redis.Redis and redis.StrictRedis classes to use redislite, so existing python code that uses Redis can use the redislite version.

Examples

Here are some examples of using the redislite module.

Setting a value

Here we open a Python shell and set a key in our embedded Redis db. Redislite will automatically start the Redis server when the Redis() object is created and shut it down cleanly when the Python interpreter exits.

>>> from redislite import Redis
>>> redis_connection = Redis('/tmp/redis.db')
>>> redis_connection.keys()
[]
>>> redis_connection.set('key', 'value')
True
>>> redis_connection.get('key')
'value'

Persistence

Now we open the same Redis db and access the key we created during the last run. Redislite will automatically start the Redis server using the same configuration as last time, so the value that was set in the previous example is still available.

>>> from redislite import Redis
>>> redis_connection = Redis('/tmp/redis.db')
>>> redis_connection.keys()
['key']
>>> redis_connection.get('key')
'value'

Compatibility

It's possible to MonkeyPatch the normal Redis classes to allow modules that use Redis to use the redislite classes. Here we patch Redis and use the redis_collections module.

>>> import redislite.patch
>>> redislite.patch.patch_redis()
>>> import redis_collections
>>> td = redis_collections.Dict()
>>> td['foo']='bar'
>>> td.keys()
['foo']

Running and using Multiple servers

Redislite will start a new server if the redis rdb fileame isn't specified or is new. In this example we start 10 seperate redis servers and set the value of the key 'servernumber' to a different value in each server.

Then we access the value of 'servernumber' and print it.

>>> import redislite
>>> servers = {}
>>> for redis_server_number in range(10):
...     servers[redis_server_number] = redislite.Redis()
...     servers[redis_server_number].set('servernumber', redis_server_number)
...
True
True
True
True
True
True
True
True
True
True
>>> for redis_server in servers.values():
...     redis_server.get('servernumber')
...
b'0'
b'1'
b'2'
b'3'
b'4'
b'5'
b'6'
b'7'
b'8'
b'9'

Multiple Servers with different configurations in the same script

It's possible to spin up multiple instances with different configuration settings for the Redis server. Here is an example that sets up 2 redis server instances. One instance is configured to listen on port 8002, the second instance is a read-only slave of the first instance.

>>> import redislite
>>> master=redislite.Redis(serverconfig={'port': '8002'})
>>> slave=redislite.Redis(serverconfig={'slaveof': "127.0.0.1 8002"})
>>> slave.keys()
[]
>>> master.set('key', 'value')
True
>>> master.keys()
['key']
>>> slave.keys()
['key']
>>>

More Information

There is more detailed information on the redislite documentation page at http://redislite.readthedocs.org/en/latest/

Redislite is Free software under the New BSD license, see LICENSE.txt for details.

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

redislite-6.0.674960.tar.gz (1.9 MB view details)

Uploaded Source

Built Distributions

redislite-6.0.674960-cp39-cp39-manylinux2010_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

redislite-6.0.674960-cp39-cp39-manylinux1_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.9

redislite-6.0.674960-cp38-cp38-manylinux2010_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

redislite-6.0.674960-cp38-cp38-manylinux1_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.8

redislite-6.0.674960-cp37-cp37m-manylinux2010_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

redislite-6.0.674960-cp37-cp37m-manylinux1_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.7m

redislite-6.0.674960-cp36-cp36m-manylinux2010_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64

redislite-6.0.674960-cp36-cp36m-manylinux1_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.6m

File details

Details for the file redislite-6.0.674960.tar.gz.

File metadata

  • Download URL: redislite-6.0.674960.tar.gz
  • Upload date:
  • Size: 1.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for redislite-6.0.674960.tar.gz
Algorithm Hash digest
SHA256 6ffc1c2233d5ca036f907e521ca8e0e0d5ce9957357e18de997332b4978357de
MD5 6e4f7bcda38b67f976bca7620ec3cf4a
BLAKE2b-256 d6a237a5558f9078518d259303dc8c297380a84bf206a9de083d41ae26f94c0d

See more details on using hashes here.

File details

Details for the file redislite-6.0.674960-cp39-cp39-manylinux2014_x86_64.whl.

File metadata

  • Download URL: redislite-6.0.674960-cp39-cp39-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 4.5 MB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for redislite-6.0.674960-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1ea50ae4da7ca65e618b5103bde77e0d27c0458c619a6c2f57d3069c04c2c5b3
MD5 b9578ff89910de20cf0d1e3e2580c8f5
BLAKE2b-256 4c93d784b38f5ef60bd73db21c7492a202c78492817e11e282f1a3acc86c18a7

See more details on using hashes here.

File details

Details for the file redislite-6.0.674960-cp39-cp39-manylinux2010_x86_64.whl.

File metadata

  • Download URL: redislite-6.0.674960-cp39-cp39-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: CPython 3.9, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for redislite-6.0.674960-cp39-cp39-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 50e6c92dd07bc65dc64658b6bae2959d23e9e1ac85bfdb8214aab3ac8b30e807
MD5 1b716c3c298a9b7a720610144affe4fb
BLAKE2b-256 c0c61e44ec53b8bb9ba319ebe47e96cc7448cdfb9c5d0bddd6fac6a1cb44325f

See more details on using hashes here.

File details

Details for the file redislite-6.0.674960-cp39-cp39-manylinux1_x86_64.whl.

File metadata

  • Download URL: redislite-6.0.674960-cp39-cp39-manylinux1_x86_64.whl
  • Upload date:
  • Size: 4.0 MB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for redislite-6.0.674960-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 472abdf314ca20ba72e33864fd52405a8679a15433069180fba6c5baa3566918
MD5 7e7a91bcb93f1509f724ad8f5c3dd3ac
BLAKE2b-256 90c88a853c9b7ca318cc5e6d713b17dc01886ec01929f8a115658a189e34f888

See more details on using hashes here.

File details

Details for the file redislite-6.0.674960-cp38-cp38-manylinux2014_x86_64.whl.

File metadata

  • Download URL: redislite-6.0.674960-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 4.5 MB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for redislite-6.0.674960-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 66c927fae6df8e40d2f5ff16d47f3f4708ee62a37562394ebc18bacf8c99c034
MD5 4453e9e54ba0f1814050cd0e5449babd
BLAKE2b-256 49d6eb66d24254ff876dc4cba65d7888b40a276d3e54abd06271ca438ce78d7e

See more details on using hashes here.

File details

Details for the file redislite-6.0.674960-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: redislite-6.0.674960-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for redislite-6.0.674960-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 9859ca5d24bb0594a61c3cba87f62ec46934e3f539bb8cab373c53bcdb6f0a97
MD5 ab98c760832388b351b567ad23a73d91
BLAKE2b-256 53ca633fa416f8a10655fca00dbf025f355b7ae8d366fd176637eabb3a6e8fe7

See more details on using hashes here.

File details

Details for the file redislite-6.0.674960-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: redislite-6.0.674960-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 4.0 MB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for redislite-6.0.674960-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 10551f3c3acbb45e6b398120f4586d02cbf0a1499ede06b7817be6111c645089
MD5 8885b43e7c4f4e3bd953e07fd72a3ce0
BLAKE2b-256 87ea53af7949362d0cb4bdc9539d4dfb2c2b4fa8358d5b90c4e933bbb0914aea

See more details on using hashes here.

File details

Details for the file redislite-6.0.674960-cp37-cp37m-manylinux2014_x86_64.whl.

File metadata

  • Download URL: redislite-6.0.674960-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 4.5 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for redislite-6.0.674960-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 170eb1353e3ea56c58d58019029eb4797a24a4b9996dc8a8df2f774b66e54803
MD5 7bbf2ab2dc2d4260e496fc715ad7eae3
BLAKE2b-256 8b662e4fd81f498b7aa9c81130a9fac07cadfe3a6148f5312a32cb7d9912f2c8

See more details on using hashes here.

File details

Details for the file redislite-6.0.674960-cp37-cp37m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: redislite-6.0.674960-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for redislite-6.0.674960-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 937e4a200402590b02aff537a6327322162f02c0b8bf359e063ed680dc4f8bd3
MD5 fa002e24f756ee0f873881ecdab7cf8a
BLAKE2b-256 532149b88e271797e6864ec3a55bfd0510f89adb7568ff2596c2619918088840

See more details on using hashes here.

File details

Details for the file redislite-6.0.674960-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: redislite-6.0.674960-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 4.0 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for redislite-6.0.674960-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ab26ec837b0c1a744e58288e2986c48b0c18773071efba5072117640e3795bd3
MD5 3fa5481d5c2ad713dbc8807580a71220
BLAKE2b-256 893171cfe2beae49c6995ba193d48ad39821edc8a6e997c49847bddede9ef4f7

See more details on using hashes here.

File details

Details for the file redislite-6.0.674960-cp36-cp36m-manylinux2014_x86_64.whl.

File metadata

  • Download URL: redislite-6.0.674960-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 4.5 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for redislite-6.0.674960-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f27402586a9639b66aeb59189e44d027065a71c7c01e56b701be865de8406fe8
MD5 bb2dfe25ce69513279d21fada8969109
BLAKE2b-256 5791c2d0e2c096d30539707c608742675c55db6fe928d047fa6267a20a8a14c6

See more details on using hashes here.

File details

Details for the file redislite-6.0.674960-cp36-cp36m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: redislite-6.0.674960-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for redislite-6.0.674960-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 c75a09b26ef05335e7276f416352f1af0db57e80cff25fe8aac38b92fffd0215
MD5 4f34d02f8a0bacfd8d9aafd41d5ddde5
BLAKE2b-256 00445b6d25db3b52d09dae49d68de245126a3a9d7f0106cb66f8ac3cf5575d16

See more details on using hashes here.

File details

Details for the file redislite-6.0.674960-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: redislite-6.0.674960-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 4.0 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for redislite-6.0.674960-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 24c02a9b644d3397616989d93175a8b4c9940fbafe3a6b244c1513e0778c99d9
MD5 d1df4cc8df9a04cbb420c8336915953c
BLAKE2b-256 eb0f5d5e3ab6ecf18be7736d9aba59621d8a2936615f6fe41a4819df7f5ab138

See more details on using hashes here.

Supported by

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