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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

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

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

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

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

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

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

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

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

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

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

redislite-5.0.165068-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.165068.tar.gz.

File metadata

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

File hashes

Hashes for redislite-5.0.165068.tar.gz
Algorithm Hash digest
SHA256 9c3cb868ba2b69f9f64d3428c1f0598c6b264aef23b0ed6f34750ec26dd73e13
MD5 55c10162d95cf57a882c0bd1af3a06bc
BLAKE2b-256 329a67f3c2fd344093a87de0ac021f9cfba2b5244df119ec60b374caddca7ff0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.165068-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.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.5

File hashes

Hashes for redislite-5.0.165068-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4c9aa71f25c14ceef8eced3236bb616e2bd6ae7138231148ed5bb6c1535205f1
MD5 56fe2bab909e137810356ea06df9b26b
BLAKE2b-256 b1306545720489ffa27b8dc0ddd5faca7f0147e404e40c7647adc0bb5f4e7e20

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.165068-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.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.5

File hashes

Hashes for redislite-5.0.165068-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 7d919b890aceb34c90203ef6de5392a66e1ed11ee91e61d38222689a71f4dab1
MD5 ef92e94c6d98c4de2024669811fddbd8
BLAKE2b-256 43561c284e9592243e70e9178dec263a52aea01a7631336fce11b924f4376835

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.165068-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.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.5

File hashes

Hashes for redislite-5.0.165068-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f5dc04f5f128d28ae0b660a194f8840489038a357df7000606f8b7348562d0ca
MD5 0050eac22f6db5a81528784b4bdeedac
BLAKE2b-256 dbe4338bbc0977a9959bc9460194e2260531f301f921e324b25419776dc8549a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.165068-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.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.5

File hashes

Hashes for redislite-5.0.165068-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 a410811b4659ae97d3e02d77a7451dbb6977035386e16ae24e42be38a83c7f27
MD5 0e7169d65b6043b226e2832f833c23f3
BLAKE2b-256 1c17bca0216f8d65c03d77b8f65d70b86cae2b444cdf9410b98ead8b43e2b7c1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.165068-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.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.5

File hashes

Hashes for redislite-5.0.165068-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dd9dcb82fce1634fd785041635f15e1eae4f7290a3c3d35653079576f1e4b468
MD5 bd44c98a91d58f61ee9b1d1412b9ae66
BLAKE2b-256 86da60312f1861d3bc78423ea3ab61902ad99c3eefea95d830a5aba141521ba6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.165068-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.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.5

File hashes

Hashes for redislite-5.0.165068-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 dbf83acbb35c3d0221595b5f530afda600f3fc65bd6f6d1a9d06d8304b76974a
MD5 3b685819c9bc233f18a7b87533863463
BLAKE2b-256 842c95e8e4d359ef3ccd0033f812fcfb7ec414e13f9338f147021bcaac33a0ea

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.165068-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.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.5

File hashes

Hashes for redislite-5.0.165068-cp35-cp35m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 983f079d92a1ef11402987fae16faa8e6054cb7f1761762b8f0239ac281bcb1a
MD5 0547b2a4b03c52ecf2ebc82e4d0a9eeb
BLAKE2b-256 c61bfd1ae3f6bf9ccb396fb58732c10a5f6ed41ed8748230d793169d7e556936

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.165068-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.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.5

File hashes

Hashes for redislite-5.0.165068-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 7442f342f739de8df4dc3e919fc44f4afff71311dfb7edd937d9db4af5879787
MD5 e9785e4d1a2c2b9a26f03cac0cc63287
BLAKE2b-256 8075494db48db8398ae4590c5cca50656022bdbdb19ac203c0256823ee277be4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.165068-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.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.5

File hashes

Hashes for redislite-5.0.165068-cp34-cp34m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 6fea5b76371a43786d8da56c33daa743be16595587aede16380e250c102b8c66
MD5 54c9b56e3f78380804f6378cc2c9b936
BLAKE2b-256 f8c80737de52d24d4333de56d17f9b128a6310d6ff4be97015cd2aa8c0aadfd7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.165068-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.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.5

File hashes

Hashes for redislite-5.0.165068-cp27-cp27mu-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 9cb7e3414cba8295869849368c951cfc6c280dd07bd387695c3123b31afac1f1
MD5 062b14da110176d1984a165107b983d2
BLAKE2b-256 944819026614faf1845021d8f228dd6d5432ffe67e62aca54453cc5781d53991

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.165068-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.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.5

File hashes

Hashes for redislite-5.0.165068-cp27-cp27m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 7a6a7f2169ce6cfcda45940872bb74a7e177d277142fea47ff3c574c182a3146
MD5 d5166f505fce6a63a8347ce801f282c4
BLAKE2b-256 bad054e59e103e8cfdb2cd55a8711cd2cf197b503baba8dcc17a138692d5eb84

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