A simple caching library for Python
Project description
Simple Caching Library for Python
Summary
Simple caching library for supported providers. Pass method call to caching provider along with generated key to populate memcached with the result. The results will be returned with a boolean value if there was a cache miss to assist in any metrics generation.
Versions
0.0.1 - Support for memcached and json conversion
Getting Started
-
Instantiate the provider:
from simplecache.common.json_conversion import JsonConversion from simplecache.providers.memcached import MemcachedProvider memcached = MemcachedProvider(JsonConversion(), servers='127.0.0.1')
-
PUT data into Memcached:
data = { 'test1': 'value1', 'test2': 'value2' } memcached.put('testkey1', 60, data)
-
GET data by key from provider. Optionally: Pass a method for a cache miss to load data into provider from the result.
class TestClass(object): def test_method(self, param1, param2): data = { 'test1': 'value1', 'test2': 'value2' } if param1 != 'p1' or param2 != 'p2': raise Exception('Unexpected error.') return data t = TestClass() # test local instance of memcached with cache miss response, miss = memcached.get( 'testkey2', 60, t.test_method, param1='p1', param2='p2')
-
DELETE data by key from provider.
memcached.delete('testkey1')
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pysimplecache-0.0.1.tar.gz
(3.7 kB
view hashes)
Built Distributions
Close
Hashes for pysimplecache-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12f047079247c3f057fb2091eab3f1e4be57c1923af80672076aeac759c4f9d5 |
|
MD5 | 78a223f2addf204b9ab1543482bd6baa |
|
BLAKE2b-256 | 5d8db7141abe941facd0459b679a850809d0095a1d1462160cb33ee425cd18e0 |
Close
Hashes for pysimplecache-0.0.1-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85de7b5e6381153c3ede48222988230a9046165240f67464857907b7ec8daf1f |
|
MD5 | d7bce7df289eb896574701d660243ca9 |
|
BLAKE2b-256 | 023ca9bd868ae55742534cd1af91433dc5a87999c0176c7c1dc3d06055b578ab |