Skip to main content

redislite

https://img.shields.io/travis/yahoo/redislite.svg https://img.shields.io/coveralls/yahoo/redislite.svg https://img.shields.io/pypi/dm/redislite.svg https://img.shields.io/pypi/v/redislite.svg https://img.shields.io/badge/python-2.7,3.4,pypy-blue.svg https://img.shields.io/pypi/l/redislite.svg
Documentation Status IRC Yahoo Group pythonredislite

Description

Self contained Python interface to the Redis key-value store.

It makes it possible to use Redis securely without the need to install and configure a redis server.

Requirements

The redislite module requires Python 2.7 or higher.

Installing 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 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

Installation

To install redislite, simply:

$ pip install redislite

or using easy_install:

$ easy_install redislite

or from source:

$ python setup.py install

Getting Started

>>> import redislite
>>> r = redislite.StrictRedis()
>>> r.set('foo', 'bar')
True
>>> r.get('foo')
'bar'

Usage

redislite provides enhanced versions of the 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 a new one.

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.

Example

Here we open a Python shell and set a key in our embedded Redis db

>>> from redislite import Redis
>>> redis_connection = Redis('/tmp/redis.db')
>>> redis_connection.keys()
[]
>>> redis_connection.set('key', 'value')
True
>>> redis_connection.get('key')
'value'

Here we open the same Redis db and access the key we created during the last run

>>> from redislite import Redis
>>> redis_connection = Redis('/tmp/redis.db')
>>> redis_connection.keys()
['key']
>>> redis_connection.get('key')
'value'

It’s also 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']

Finally it’s possible ot spin up multiple instances with different configuration values for the Redis server. Here is an example that sets up 2 redis instances. One instance is configured to listen on port 8002, the second instance is a read-only slave of the first instance.

Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 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 3.0.296

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 3.0.296
File Size Uploaded
redislite-3.0.296.tar.gz 1.7 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for redislite 3.0.296
File Interpreter ABI Platform
redislite-3.0.296-cp35-cp35m-macosx_10_6_intel.whl CPython 3.5 CPython 3.5 pymalloc macOS 10.6+ Intel (x86-64, i386) Details
redislite-3.0.296-cp34-cp34m-macosx_10_6_intel.whl CPython 3.4 CPython 3.4 pymalloc macOS 10.6+ Intel (x86-64, i386) Details
redislite-3.0.296-cp27-none-macosx_10_6_intel.whl CPython 2.7 none macOS 10.6+ Intel (x86-64, i386) Details

Total release size: 4.6 MB

Release files / redislite-3.0.296.tar.gz

Download URL redislite-3.0.296.tar.gz
Size 1.7 MB
Tags Source
SHA-256 checksum
How to use checksums
95347f4d50af3c4ff19a01c5779915890b0934a8d28a7e038ef0f76e406beef2
BLAKE2b-256 checksum
How to use checksums
6a889e51c7b7b2891952b2c79215a5e0ab16df7407c02e8708c39f010a1cda4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / redislite-3.0.296-cp35-cp35m-macosx_10_6_intel.whl

Download URL redislite-3.0.296-cp35-cp35m-macosx_10_6_intel.whl
Size 959.3 kB
Tags CPython 3.5 CPython 3.5 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
87fffb7cb2d11946b1bf6787763e560ee4d03c41e392567233e75c48cc92f88f
BLAKE2b-256 checksum
How to use checksums
a52d505320c094c9070a7bbc01ec1d66f39623b106b3638c7874aa5a75576462
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / redislite-3.0.296-cp34-cp34m-macosx_10_6_intel.whl

Download URL redislite-3.0.296-cp34-cp34m-macosx_10_6_intel.whl
Size 959.2 kB
Tags CPython 3.4 CPython 3.4 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
23005f39168c3eaf5bd1fb10f9ffd6441afecef9c3401c64e8c56a3c7fab35d6
BLAKE2b-256 checksum
How to use checksums
9084b46c388cd6fca7ba76b6b99f7219d71144cdcaae233e253a85286669dc59
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / redislite-3.0.296-cp27-none-macosx_10_6_intel.whl

Download URL redislite-3.0.296-cp27-none-macosx_10_6_intel.whl
Size 959.2 kB
Tags CPython 2.7 macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
849693ade065babba2bfe037b6d19d906ff9013cd0b50a19c2abbb60056cc85b
BLAKE2b-256 checksum
How to use checksums
9ebae9b743b35ce16ef3ce2f58bf8f467c228651db4becf895b61d1015512437
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

3.2.310

1 release file

This release

3.0.296 This release

4 release files

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