Skip to main content

Redis built into a python package

Project description

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 without the need to install and configure a redis server.

Requirements

The redislite module requires Python 2.7 or higher.

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

On Mac OSX 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

Note redislite and its dependecies use the gcc compiler. On OSX you may run into errors indicating that your machine is using clang to compile instead, for example:

clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]

If this is the case, set your environment variable to override the use of clang in favor of gcc:

CC=gcc

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']

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

Uploaded Source

Built Distribution

redislite-1.0.216-cp27-none-macosx_10_6_intel.whl (857.2 kB view details)

Uploaded CPython 2.7 macOS 10.6+ intel

File details

Details for the file redislite-1.0.216.tar.gz.

File metadata

  • Download URL: redislite-1.0.216.tar.gz
  • Upload date:
  • Size: 3.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for redislite-1.0.216.tar.gz
Algorithm Hash digest
SHA256 46e7598199e2b9690affb543bfd62b6eb8d440e0664fcb41e5ac48f3e68faed9
MD5 24e35b009ed33f772ff9459fd54ca02d
BLAKE2b-256 cc1a212e39c3beffdcf494f46d7b0a285af0a35e68af14646dbdbd4da03cd228

See more details on using hashes here.

File details

Details for the file redislite-1.0.216-cp27-none-macosx_10_6_intel.whl.

File metadata

File hashes

Hashes for redislite-1.0.216-cp27-none-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 876d24f0b7d70e39ff507a21c7707fa34b2f41311c543661894d10adfb5ddd07
MD5 28ce88d6dafa7f9a485db35b0bd55950
BLAKE2b-256 e9a009a3f12345acad6176a803424822312a0a0fc0d8625b1f016b3332205e8c

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