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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

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

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

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

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

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

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

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

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

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

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

redislite-5.0.159960-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.159960.tar.gz.

File metadata

  • Download URL: redislite-5.0.159960.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.159960.tar.gz
Algorithm Hash digest
SHA256 fb0c0148feb2b6e4fe2da2cc359410bc756b5f586e5027da740b3268f2d87811
MD5 4b3670355f150c2f88dd3b620f883daa
BLAKE2b-256 4426d8475136ee92ea7498b11c5f46eeb5263f463cdcd2cc8e1e189d9eaa0bd3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.159960-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.159960-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0abbaa8ecf7223fb708a326a6548f0fda98ee3e8a270d0d52e9e2c6d21eb996d
MD5 c6e41fb27a6aa9715165614d06d954b0
BLAKE2b-256 bae44ec9116a4e786dcf619c03049ed0d05df208274a2d6e25ab8a7a15d2e4b1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.159960-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.159960-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 d73743ef9af5cd3268d71a636eb3f96825a8db4d7da030cf64c7607b95fc3ef7
MD5 463a2e4a25ba53dbe64acc5de07dfb88
BLAKE2b-256 70b8a0ccf49d728d418b4827405c385d1138b3d3836b5c0d30aafe3c0fe6a8ec

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.159960-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.159960-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 837f6146193a724cf9c597e5c5b6e036663fb288061e68177805fe1cd6ed0aa8
MD5 ea60d4122169e8cd4c60b8e4a7f63335
BLAKE2b-256 61a01203530dd2671469670c8e98e78bf5dece98f7dfeb912802f47646b38072

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.159960-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.159960-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 514363c8d3b6b189ea2591fbefb23f73ab56a50e497b59bfabc8a6ed137bf5d1
MD5 2c9c4f6de7e1c228c506b42801c8ad1d
BLAKE2b-256 464211aede420fec15265fd84bb40982c63912da2f45fdecb3b58158d1f3233c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.159960-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.159960-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 914ad3383e0f76cdca274ff6e07d3487a3414562994633d631e1b8e626a6c2aa
MD5 dbe3dffb9b2a6412fc717b669d5e6d75
BLAKE2b-256 5e4c7ec97046fa18e748245469c98deb3cb2f426208aba787f9940f9493ee129

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.159960-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.159960-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 d91ac91280ffab49dee3f5856e12046360b1eac0122441b98acc9808c88802b5
MD5 f80a333146bff799ae4ce12b8276adb6
BLAKE2b-256 f74bc77e82e0f757a88a5e73cc00cbea99a55df041edb5fea60d3f9b3e03228d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.159960-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.159960-cp35-cp35m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bb434bcde9ca37823e20fcf515dcf83220c972e972d489bba1857dbcd9a5e6c5
MD5 4ebf05437b0a4734b15c94dcd1b44f8e
BLAKE2b-256 666c9b403955f7c44879e4602262bf375057552c365754cc17e427fd139d3077

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.159960-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.159960-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 c31c0776cfa6d4615854911d12de7b0a0c7a85af08ee3dfeab460697df562815
MD5 e1a56b22ca7f8459eb919bad71f885e2
BLAKE2b-256 7e49f93bf826838047c6ebd5fc8392ea1d3a18ccd38459b939bdfd43fb0d647f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.159960-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.159960-cp34-cp34m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 ad1f8c6bc3ead80d1b98d66c9afa8e41df796eb61a7a7a53e9ad6e432d1a6a62
MD5 0ea55bc66390b3503c67fc82bbff936f
BLAKE2b-256 51a70a748e0cfcaece2f246668968a38216f7b9b8aa56b09cafdbc0657207aba

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.159960-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.159960-cp27-cp27mu-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 ab809f1f28f815dce412293a4189bc3c55996c5feb1b119709c34ab13269cb81
MD5 2f870e3c9f39d5e74cbc6fe34b524275
BLAKE2b-256 e78c3ed92bc9a9c6232f2a8d8cff467a5489dd8afe460334a8b52cf2d5091a4f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.159960-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.159960-cp27-cp27m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 7010b2fa78504531704b98aa0f5ea0ccdc3706db63148aedb0b9510e8b7e852d
MD5 324e39e241ca559475610b9eceecaf0d
BLAKE2b-256 ab3ae9d9038f7c61d82435c321640b87e6e0b68a78db4105e29113072f9a7e29

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