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.

Source Distribution

indicium-0.1.0a3.tar.gz (11.3 kB view details)

Uploaded Source

File details

Details for the file indicium-0.1.0a3.tar.gz.

File metadata

  • Download URL: indicium-0.1.0a3.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for indicium-0.1.0a3.tar.gz
Algorithm Hash digest
SHA256 294e491e93e853dd4bc1358042be5f863c20b2c1d2c8ed7690095f22256200d0
MD5 11177273b8fd19abef5a12d3f8a0ef4d
BLAKE2b-256 fdffcb7ed6c19be11d39644af4f9ae2235c3ccef1187ef0d4d80760404fd8be1

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