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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded CPython 3.8manylinux: glibc 2.12+ x86-64

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

Uploaded CPython 3.7mmanylinux: glibc 2.12+ x86-64

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

Uploaded CPython 3.6mmanylinux: glibc 2.12+ x86-64

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

Uploaded CPython 3.5mmanylinux: glibc 2.12+ x86-64

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

Uploaded CPython 3.4mmanylinux: glibc 2.12+ x86-64

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

Uploaded CPython 2.7mumanylinux: glibc 2.12+ x86-64

redislite-5.0.165276-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.165276-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: redislite-5.0.165276-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.165276-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 157db8bd46a28549870078cbb7f8ee6f819866cfde1dc05fb12577551a15250e
MD5 138c2d57834867f92420459c804c24bb
BLAKE2b-256 e14fea480bbc62f35d136a7f1260292d0033539e196772c693c1a335bb7eb2c7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.165276-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.165276-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 1f60e86a71e09efed12d2acc11baf4bc151e1a3f95b80bcb1fc616cbd4672740
MD5 487a94812d29a8b807ac53f5b5d7ca9c
BLAKE2b-256 53df08aac53273abfd20bcaaaf3d9beb9afbbae912e6956318dcb4979a22ffc0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.165276-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.165276-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 c4b948cb47838e874f26db544d22eda2cd90eee6001aaf8d3d700575358302d7
MD5 2398e2a45964dc9ec5088fd3112ee062
BLAKE2b-256 516856691c58bf4bf43f7e8a457eef9247bdc67c32c6554b9acb5b7c619ef94f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.165276-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.165276-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 b6313a70020869b90dc80c01ba9c947873e5a74e497ef605d29aa8a797409c00
MD5 4aeb935e3126d43fc0c1b891e0b5d7e2
BLAKE2b-256 18eaf338c81b8134b46ec7a2643bbacd715f5bf78f5d4783f247a0f81bd10a72

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.165276-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.165276-cp34-cp34m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 b7675e77d66d228c46078f7613ceb3d80b98eb5c87ae782e34a040971af19062
MD5 30df006c487ffb595a1cc2b67828b972
BLAKE2b-256 8e49d54e6c8479ac1336d013d80e1076bc4641c85322ba4333e72837c69212f3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.165276-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.165276-cp27-cp27mu-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 3bcc3503f07815ddde1cef28d37cf25044a0d923f39f66ae816ea1cdceee3209
MD5 f8a5486963199c5f3866243535454caa
BLAKE2b-256 44ea1eaf111e19b008e5694b81cae3431ba72f22e16b9f30896629e2f91c6196

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redislite-5.0.165276-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.165276-cp27-cp27m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 0578003fd657fe1641073698013f2ea3603df20f80eb321a9fcd13ea5c106fc9
MD5 6a3433037e2fa3c96e56fcc807300f32
BLAKE2b-256 cc4836c39774850aa00fdec1b054609a7ca0cbe59c729eeee97bfdcb7459b297

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