Skip to main content

Generic interface to key-value stores

Project description

Documentation Status Build Status Code Coverage

Pythonic, unified API to multiple key-value stores.

This base package includes:

Support for additional storage system is by packages distributed separately:

  • indicium-git.
  • indicium-ldap.
  • indicium-leveldb (planned, not yet available).
  • indicium-memcache (planned, not yet available).

Usage

Create a Store which saves content on-disk, using JSON for serialization, and store somwthing that resembles an user account:

from indicium.base import Serializer
import json

filestore = Serializer(FSStore("./data", extension=".json"), pickle)
filestore.put("/user/jdoe", { "id": "jdoe", "name": "John Doe",
        "email": "j@doe.org", "password": "supersekrit" })
account = filestore.get("/user/jdoe")
assert account["email"] == "j@doe.org"

The ./data/user/jdoe.json will contain the account data in JSON format. The following adds an in-memory cache to the above store, which holds up to 100 elements, to speed up access to data:

from indicium.cache import LRUCache

cachedstore = LRUCache(filestore, size=100)
account = cachedstore.get("/user/jdoe")
assert account["email"] == "j@doe.org"

Once you have a collection of objects, you can run use queries to retrieve all the elements whose keys match a certain pattern. For example, this obtains the user accounts with an identifier starting with the letter j from the store above:

for key, account cachedstore.query("/user/j*"):
    print(account["id"], account["name"])

Installation

All stable releases are uploaded to PyPI, so you can install them and upgrade using pip:

pip install indicium

Alternatively, you can install the latest development code —at your own risk— directly from the Git repository:

pip install git://github.com/aperezdc/indicium

Development

If you want to contribute, please use the usual GitHub workflow:

  1. Clone the repository.
  2. Hack on your clone.
  3. Send a pull request for review.

If you do not have programming skills, you can still contribute by reporting issues that you may encounter. Contributions to the documentation are very welcome, too!

Inspiration

  • Park
  • datastore (unfortunately, it does not support Python 3.x).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for indicium, version 0.1.0a3
Filename, size File type Python version Upload date Hashes
Filename, size indicium-0.1.0a3.tar.gz (11.3 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page