Skip to main content

Redis built into a python package

Project description

Redislite

Build Status 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 2.7 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.

Download files

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

Source Distribution

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

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

redislite-5.0.159945-cp38-cp38-manylinux2014_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.8

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

Uploaded CPython 3.8manylinux: glibc 2.12+ x86-64

redislite-5.0.159945-cp37-cp37m-manylinux2014_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.7m

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

Uploaded CPython 3.7mmanylinux: glibc 2.12+ x86-64

redislite-5.0.159945-cp36-cp36m-manylinux2014_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.6m

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

Uploaded CPython 3.6mmanylinux: glibc 2.12+ x86-64

redislite-5.0.159945-cp35-cp35m-manylinux2014_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.5m

redislite-5.0.159945-cp35-cp35m-manylinux2010_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.5mmanylinux: glibc 2.12+ x86-64

redislite-5.0.159945-cp34-cp34m-manylinux2010_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.4mmanylinux: glibc 2.12+ x86-64

redislite-5.0.159945-cp27-cp27mu-manylinux2010_x86_64.whl (4.4 MB view details)

Uploaded CPython 2.7mumanylinux: glibc 2.12+ x86-64

redislite-5.0.159945-cp27-cp27m-manylinux2010_x86_64.whl (4.4 MB view details)

Uploaded CPython 2.7mmanylinux: glibc 2.12+ x86-64

File details

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

File metadata

  • Download URL: redislite-5.0.159945.tar.gz
  • Upload date:
  • Size: 1.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5

File hashes

Hashes for redislite-5.0.159945.tar.gz
Algorithm Hash digest
SHA256 167e3ad1aaaa430c2f7b4121340c3c88dacce42e780514c792d431df9d3185a1
MD5 4778f68fc9848e2627db06e5017837f3
BLAKE2b-256 4fd200fd31b38ac8f065b7b188942e6fcfa460e9ed54b1e276c134d3a578d627

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.159945-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 4.3 MB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5

File hashes

Hashes for redislite-5.0.159945-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 380745e730d3a9e84ec5a6c3039597b3ef0bb49204f77e78f62564716a72ed9d
MD5 0ab28fdb1b76b9820ef750005a22c4ea
BLAKE2b-256 4f7f2bf55903488077eaa6917d064494d33e6b8911a6c086210e014575c8eaaa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.159945-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.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5

File hashes

Hashes for redislite-5.0.159945-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 8524f558aa70160eb88254474129111e7f645609350055551e9bc299e86b2064
MD5 68d231189f4e6a5ef2e81d1d7d95ecbf
BLAKE2b-256 154ea3cc59660413b4579fc4d487ce8c50f5472a927f4959285891c75be32660

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.159945-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 4.3 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5

File hashes

Hashes for redislite-5.0.159945-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e518c5c6fb3ef29878c8adc8c8d9b37ae7f5ea8363e98a33f91a5bf71b465bbe
MD5 05c259d80f4338dbb9ea3aec9a1d6438
BLAKE2b-256 e5c3c19630ad567c5b31a72d44ba6ef670d2a851e5172858356393288358be4a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.159945-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.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5

File hashes

Hashes for redislite-5.0.159945-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 5404e0fae3b5220333ce1e36eda6a66b13644255040f3bf138da6a2549ede475
MD5 b24fb6513bd61f7752427e21c68494c9
BLAKE2b-256 0fa4a3be6993b921249cbb0efafeeb1d647841d016bad66abd367a84a6f24227

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.159945-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 4.3 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5

File hashes

Hashes for redislite-5.0.159945-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f6b8748322a73b680d98855c576895ca9756012e0f193582b0eaa01832f345bb
MD5 4424124eb411a256a71909a95e865776
BLAKE2b-256 ae055c1d437b0f4fa389ea55d4c718678a9ca986e0bb02f041a743f9ffa07ab2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.159945-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.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5

File hashes

Hashes for redislite-5.0.159945-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 9a67ca8353b9279fc44b3317b48f9c67660834a4fb73710ac81f2a0f2d385437
MD5 c5bc6032b88fa149f74435496f8b17c3
BLAKE2b-256 b076fc4f32a8545431b707bb96d1e23d04605d078539dcbe05ef64cea1e55c99

See more details on using hashes here.

File details

Details for the file redislite-5.0.159945-cp35-cp35m-manylinux2014_x86_64.whl.

File metadata

  • Download URL: redislite-5.0.159945-cp35-cp35m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 4.3 MB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5

File hashes

Hashes for redislite-5.0.159945-cp35-cp35m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 45ca87e7db26634d31a86dc2fd8131eb5dc03360bcb9b5086595550dd4f9d6b8
MD5 670510c049533683fbaea0b99c77bdbf
BLAKE2b-256 ff6b148fd89279ae4b04e85a8240f795385688f9c99e14f4a8f1a07f2068e206

See more details on using hashes here.

File details

Details for the file redislite-5.0.159945-cp35-cp35m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: redislite-5.0.159945-cp35-cp35m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: CPython 3.5m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5

File hashes

Hashes for redislite-5.0.159945-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 4b8ea955e962de919c9d1c4efb41e87dd1d1d9c2d394edcd547583ce81b52fc6
MD5 b0dd4d272e55d130eea9e004ace95e50
BLAKE2b-256 0e47aff3e77fc7366bf8ae3c8268e14cb4638273c9abc42aa067ffc1eb6bd6ca

See more details on using hashes here.

File details

Details for the file redislite-5.0.159945-cp34-cp34m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: redislite-5.0.159945-cp34-cp34m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: CPython 3.4m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5

File hashes

Hashes for redislite-5.0.159945-cp34-cp34m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 ad5263f32ae9ee4939f4d2f8e3798f134948ef3f7bc9d0fa01c9eac7b1ab9ec3
MD5 55ddbc8925836835b7ce59e5352c930f
BLAKE2b-256 4a95f038d1d9b8eb42d56da1949d7b4b53b7ff3c6281c3b5704835db4d0d7c7b

See more details on using hashes here.

File details

Details for the file redislite-5.0.159945-cp27-cp27mu-manylinux2010_x86_64.whl.

File metadata

  • Download URL: redislite-5.0.159945-cp27-cp27mu-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: CPython 2.7mu, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5

File hashes

Hashes for redislite-5.0.159945-cp27-cp27mu-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 c293566394d1cbaf6ffd70ba9d5ba688809d45169d951acdc0dc268eab22b32a
MD5 3f12763efe172d1be34a53a8fa95e8c2
BLAKE2b-256 ae20cc75a57671d297bc4e65d6e0b38e27e766aeb723eafff4850073522a6969

See more details on using hashes here.

File details

Details for the file redislite-5.0.159945-cp27-cp27m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: redislite-5.0.159945-cp27-cp27m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: CPython 2.7m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5

File hashes

Hashes for redislite-5.0.159945-cp27-cp27m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 fc455240e8262fc61adfd7e20ee7280181c3152904cd8f2f94c80649c2237d7a
MD5 ae9a1832e6dafaa19fe62f84ac59bbe4
BLAKE2b-256 a0dad686315872440a6c43ff596d4a393a3c3b89860a0ab0c5af0937a33ffa21

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