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.159448.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.159448-cp38-cp38-manylinux2014_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.8

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

Uploaded CPython 3.8manylinux: glibc 2.12+ x86-64

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

Uploaded CPython 3.7m

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

Uploaded CPython 3.7mmanylinux: glibc 2.12+ x86-64

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

Uploaded CPython 3.6m

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

Uploaded CPython 3.6mmanylinux: glibc 2.12+ x86-64

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

Uploaded CPython 3.5m

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

Uploaded CPython 3.5mmanylinux: glibc 2.12+ x86-64

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

Uploaded CPython 3.4mmanylinux: glibc 2.12+ x86-64

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

Uploaded CPython 2.7mumanylinux: glibc 2.12+ x86-64

redislite-5.0.159448-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.159448.tar.gz.

File metadata

  • Download URL: redislite-5.0.159448.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.159448.tar.gz
Algorithm Hash digest
SHA256 321f15a4ba7e9c6e5f0aeea34a0bff64618893ed8322e6966e1bc1c427c856bc
MD5 7971499910a9a40e984bca2b6c37c55c
BLAKE2b-256 21f197c632920975cf92d90be3ea4acf97d2eb7b1c571b2616924a6a76bdf4c8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.159448-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.159448-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 96043434aa971cbce3b0675cdf4a09861c6d88ee4c2f0f24898b210b40831427
MD5 3c4e80c9fbe5576ecad248444582d81a
BLAKE2b-256 bfd7f3ff05b92a5c1309cd27d343f92413eed607efcee8111c1e77ca23e2d0b7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.159448-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.159448-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 e5890dbd42c59cecb41060ebb80aa1dd0ec7341488d54ae9488cae9783203119
MD5 76e9e5846b6db7725a4cb04fdcd22529
BLAKE2b-256 9982d5b6d401890f374e5aa81a2af0e3c2b717bcadc01178bd362a8725a293f0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.159448-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.159448-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ce16c1a98a9f4fc008b6c4cf3aa5f61001d8c55ad720aae4a33b698bc44acedf
MD5 387ad42826c8bb5ab4d523d3753bb1d2
BLAKE2b-256 bbea9b53362d90c4aa2626b900a1e57e0398871e3bb2d3392216844075e5c450

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.159448-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.159448-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 7d912b49839d2043ca6196a5806c6c7dc5f3678dfe58ed4f3173cbb9026b098e
MD5 a8486a6aa34bf0d8a2f9c3dd61f54f41
BLAKE2b-256 8e72d3d4bb422e6267603fe6ed951a538f5154585a8b9f3060befba75dc38acb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.159448-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.159448-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 704310a261f938bdabf1609916bea538aa29369c3567337fda9157121ddf613e
MD5 60cc3e8e05ec4eb3ee41ecf5c29ffe54
BLAKE2b-256 07e83e45cc23fa6821dcf10917a60fd2388cbbd12ab82dfad300d2e5d6003e9a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.159448-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.159448-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 ac361737ba6fdfe0c4ba388179947e9cf1cb69679254a8003702901d6fe53556
MD5 744b3175b86c383db84bcc3104441bcc
BLAKE2b-256 5838e7e431218aff384c7516736f42738d4258fe88927d4932aba11c4cd1db6c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.159448-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.159448-cp35-cp35m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f7b8847d211fbcce3bbe7ff2624bb0dedde19553299dbf6df9d0af327d020f82
MD5 89857e27e956a120773c822355e6ad50
BLAKE2b-256 ef67cd3f165b4f06af6a93b7704c26768e24aed4f17500eaeb239c8d08d9aa07

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.159448-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.159448-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 55aab9badd1bd9b9c64feb376ecfbe5d56b0fb6cfab0437d21e8dbeedfd22978
MD5 471843621f639308d42dd3283be4ec36
BLAKE2b-256 dcb6c765066137a195a56737ad8c944f6b863cc4fd2dc286915faa457bf7fd25

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.159448-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.159448-cp34-cp34m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 73e16ff06f28fec79f992d1c7f42206ab8ce9daa85529b97f0e76b09cb7105a6
MD5 6fd06778c6ad9a8a141418addda8267d
BLAKE2b-256 d78f4f32d91cc0d6ceef8593025ca42ce17a74689f414f8a7ca55763bbb5842c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.159448-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.159448-cp27-cp27mu-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 a9602be86b2f8f0dd48482e702490e59e70ccbdb55bbe2175ebf25e5fe676959
MD5 80cbccf269b475d0795f882112378872
BLAKE2b-256 c2620601da95e608740cb695e2cddb6ecf9aceed53030c3723db251bbc7ce8d2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.159448-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.159448-cp27-cp27m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 41db07d2ea364dd8f69fb52ca1b0e9f43de010008b15c1f1485903ab97a6c456
MD5 dedd2eece3b1b5cbe315bd324549500c
BLAKE2b-256 30bd67ff49b39d69ae2cb15c7ec11168c93a2d638b76009d590b674d25b0de2c

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