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.155417.tar.gz (1.9 MB view details)

Uploaded Source

Built Distributions

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

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

redislite-5.0.155417-cp38-cp38-macosx_10_9_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

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

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

redislite-5.0.155417-cp37-cp37m-macosx_10_9_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

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

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

redislite-5.0.155417-cp36-cp36m-macosx_10_9_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

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

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

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

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

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

Uploaded CPython 2.7mu manylinux: glibc 2.12+ x86-64

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

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

File details

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

File metadata

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

File hashes

Hashes for redislite-5.0.155417.tar.gz
Algorithm Hash digest
SHA256 0a5675df120847253c4ab93482adee9a3ab57be518546c03cc19f834ef72c2c0
MD5 8bb22ae7c55a2e6737c1896199cabd53
BLAKE2b-256 6bb200b05307a6ec586c82e8c1e493042e34c875fa47c4dd22101e277b4775c2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.155417-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/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.5

File hashes

Hashes for redislite-5.0.155417-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 ca60f25c37e8cac43d958dee8623d40d501f58afc061f1e10ef9009364079f9d
MD5 f3664567a1778e08fec4ecef3852e93a
BLAKE2b-256 98049a54641175aed2b74ab38a4654f7d24d4cc0e5f29279294606eccd58455a

See more details on using hashes here.

File details

Details for the file redislite-5.0.155417-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for redislite-5.0.155417-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 38d1d98c6eaecde6ba3127acfa298790f935f3427132c17af1ee725d9dab379e
MD5 ac562982ebc0ccdc1fe6c7b66777663e
BLAKE2b-256 0fdbb8c7313a925ff9e54927436c7121cad9a8176c52ac84f8e917efb534c1ee

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.155417-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/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.5

File hashes

Hashes for redislite-5.0.155417-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 993fa8613b7eca2956229f472b6b07a40ef1d2d5380d1ca9a0d578d766b99acf
MD5 57435bbbaa5f51685acc8cb8eb901104
BLAKE2b-256 9bb168896483484b22e6213638594749921ec86aa057e94992521e5fbac07879

See more details on using hashes here.

File details

Details for the file redislite-5.0.155417-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for redislite-5.0.155417-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 deecc4346fad396116c0bf5695199ac2d69c4e8293bc7f21ff96faec68c12049
MD5 6f8b099cae79d5c6fc1652e821bb797c
BLAKE2b-256 a991f9599a92f544c19dd6f013cb40a11b4066022c8bb11d561dab86cf6e64a5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.155417-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/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.5

File hashes

Hashes for redislite-5.0.155417-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 21830fdf7ebeb36f6a5b26e64cda49b85760cb9e5ffb206315280c906a50262a
MD5 2506036dc5f3113dc2513c8c7b4f94d9
BLAKE2b-256 d8da9896d386d046905330a36ec00b5fa962fdf64d958fd63b3a5d81492b1c6e

See more details on using hashes here.

File details

Details for the file redislite-5.0.155417-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for redislite-5.0.155417-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 77422ec27719152031d9fff8234885db92e6189669bade2d3b629023d3d47783
MD5 06ecfddad863edf28684bf8b4f7d5f8b
BLAKE2b-256 c1fc2128a56dcb65b10b6c45e44c03c499cbc9ac18f1a349ee61fac9c9a0af7c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.155417-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/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.5

File hashes

Hashes for redislite-5.0.155417-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 479ab3dec260be40af175851e0c649d3a8c8fa26307b56841645825377e68816
MD5 152a03a3f256c0fe6783e3283e9f40c3
BLAKE2b-256 bd13bed8994a1e8552c0f2fdeb2686eca560fe91b306bf03dbd05c7c5488d07d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.155417-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/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.5

File hashes

Hashes for redislite-5.0.155417-cp34-cp34m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 2798116bae4d3d93e5cac353a8e900018f983ab250e872c733e1f47b53ff0ac4
MD5 b4cf71368203d17eaaa50240b24962ee
BLAKE2b-256 f9267018647566b71a5001e8e0d632ee0b770873f7aa6fa654e048bc3f9c9ea0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.155417-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/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.5

File hashes

Hashes for redislite-5.0.155417-cp27-cp27mu-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 1652ee58bfcecb6d6ab8b54e23fa50eca2aa01960c0a4a99adce83bcd7459631
MD5 f4e4e76a6995451677e422bfa0977fd8
BLAKE2b-256 449b71d3d8e05458b33ec61501599956e2a9bb95500a7ec472a869d5d89e57f2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.155417-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/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.5

File hashes

Hashes for redislite-5.0.155417-cp27-cp27m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 b1f94c52e520ec7f1ba768b0eab4d4ead9271a8b1b8b81e235ef3ba0ccdf5450
MD5 5d402f7eb863be818e7b8f7d4e5090b3
BLAKE2b-256 5b0e171bb21137a32855c588c3ccf0be7192137607970b6efd545b586e3b70f9

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