Skip to main content

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.

Release files for redislite 5.0.158747

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for redislite 5.0.158747
File Size Uploaded
redislite-5.0.158747.tar.gz 1.9 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for redislite 5.0.158747
File
redislite-5.0.158747-cp38-cp38-manylinux2010_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.12+ x86-64 Details
redislite-5.0.158747-cp37-cp37m-manylinux2010_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-64 Details
redislite-5.0.158747-cp36-cp36m-manylinux2010_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.12+ x86-64 Details
redislite-5.0.158747-cp35-cp35m-manylinux2010_x86_64.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.12+ x86-64 Details
redislite-5.0.158747-cp34-cp34m-manylinux2010_x86_64.whl CPython 3.4 CPython 3.4 pymalloc Linux glibc 2.12+ x86-64 Details
redislite-5.0.158747-cp27-cp27mu-manylinux2010_x86_64.whl CPython 2.7 CPython 2.7 pymalloc wide-unicode Linux glibc 2.12+ x86-64 Details
redislite-5.0.158747-cp27-cp27m-manylinux2010_x86_64.whl CPython 2.7 CPython 2.7 pymalloc Linux glibc 2.12+ x86-64 Details

Total release size: 33.1 MB

Release files / redislite-5.0.158747.tar.gz

Download URL redislite-5.0.158747.tar.gz
Size 1.9 MB
Tags Source
SHA-256 checksum
How to use checksums
8d496e51b6490d866d92cc9ce618ebc446d093b46d4cab78c38794840e2c5a28
BLAKE2b-256 checksum
How to use checksums
7f4060aa33666910319b4a9aeda5d32b9ce55046a1398683d851067b79829e9b
Upload date
Uploaded using Trusted Publishing?
What is 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.38.0 CPython/3.7.5

Release files / redislite-5.0.158747-cp38-cp38-manylinux2010_x86_64.whl

Download URL redislite-5.0.158747-cp38-cp38-manylinux2010_x86_64.whl
Size 4.4 MB
Tags CPython 3.8 Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
8b1e1409d65c2b629b450b3a35e5cd5c2c0431e73cce3bf3c1ede8d480fc5391
BLAKE2b-256 checksum
How to use checksums
3e50b42beb34b18a739c1009ccfa2b85a3007dfbc0f11df13910ec492bb63956
Upload date
Uploaded using Trusted Publishing?
What is 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.38.0 CPython/3.7.5

Release files / redislite-5.0.158747-cp37-cp37m-manylinux2010_x86_64.whl

Download URL redislite-5.0.158747-cp37-cp37m-manylinux2010_x86_64.whl
Size 4.4 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
0801ab7487d362b0498e03cae12d0d4f2511068b8612e2f726a25be634b34e48
BLAKE2b-256 checksum
How to use checksums
44493f43ac31a27166ffb7f5600421dc18451a20e23bbdd9b37b22acd7e21e08
Upload date
Uploaded using Trusted Publishing?
What is 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.38.0 CPython/3.7.5

Release files / redislite-5.0.158747-cp36-cp36m-manylinux2010_x86_64.whl

Download URL redislite-5.0.158747-cp36-cp36m-manylinux2010_x86_64.whl
Size 4.4 MB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
e27bcb35ba349f81ec557ddb49c784e72e6bf51018e86e2200f27624d4b2598a
BLAKE2b-256 checksum
How to use checksums
7fcdc9c891912c5b1126798e696d910031e96fb8f4a8286533d1d0935b974606
Upload date
Uploaded using Trusted Publishing?
What is 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.38.0 CPython/3.7.5

Release files / redislite-5.0.158747-cp35-cp35m-manylinux2010_x86_64.whl

Download URL redislite-5.0.158747-cp35-cp35m-manylinux2010_x86_64.whl
Size 4.4 MB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
384e0ac798c768d1dbd1959ff026aa359394234ed17c641f234aa201030b678a
BLAKE2b-256 checksum
How to use checksums
622342c3a3e44050ff33b29a41cc6931fde0ddd918deb445a3aba7b61eaefa29
Upload date
Uploaded using Trusted Publishing?
What is 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.38.0 CPython/3.7.5

Release files / redislite-5.0.158747-cp34-cp34m-manylinux2010_x86_64.whl

Download URL redislite-5.0.158747-cp34-cp34m-manylinux2010_x86_64.whl
Size 4.4 MB
Tags CPython 3.4 CPython 3.4 pymalloc Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
81fa61a21439b29dcbcc29ceff75c23465779aa9f8e301d4660cf550c9f31600
BLAKE2b-256 checksum
How to use checksums
da42307f9f1cd35b101da0e821f92e8071f05cad0442776a40f85048534eb37f
Upload date
Uploaded using Trusted Publishing?
What is 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.38.0 CPython/3.7.5

Release files / redislite-5.0.158747-cp27-cp27mu-manylinux2010_x86_64.whl

Download URL redislite-5.0.158747-cp27-cp27mu-manylinux2010_x86_64.whl
Size 4.4 MB
Tags CPython 2.7 CPython 2.7 pymalloc wide-unicode Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
a4ae12ec9bf433ddae43d0a6c4ab3eac3eba066f86ef4aa107d4f7dceaf5b466
BLAKE2b-256 checksum
How to use checksums
e413ec61f6a16aabb35bcf190e019a9e80902a92f06178c0a997bff7c862b8f3
Upload date
Uploaded using Trusted Publishing?
What is 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.38.0 CPython/3.7.5

Release files / redislite-5.0.158747-cp27-cp27m-manylinux2010_x86_64.whl

Download URL redislite-5.0.158747-cp27-cp27m-manylinux2010_x86_64.whl
Size 4.4 MB
Tags CPython 2.7 CPython 2.7 pymalloc Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
41e680dbf17df9fd9b8cda283a4f30bc4ddad56b09a54dd4966d1dd47b5caf18
BLAKE2b-256 checksum
How to use checksums
e9e6dfc24e1a3a2d41446143c6f02f6fad9c183018963b7981bf56935cba338a
Upload date
Uploaded using Trusted Publishing?
What is 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.38.0 CPython/3.7.5

Release history Release notifications | RSS feed

This release

5.0.158747 This release

8 release files

3.2.310

1 release file

3.0.282

1 release file

3.0.273

1.0.210

1 release file

1.0.151

1 release file

1.0.93

1 release file

1.0.63

1 release file

1.0.60

1 release file

1.0.59

1 release file

1.0.38

1 release file

1.0.13

1 release file

1.0.12

1 release file

1.0.10

1 release file

1.0.9

1 release file

1.0.8

1 release file

0.0.1

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page