Skip to main content

Simple caching infrastructure.

Project description

This package is designed to be used by applications which require different kinds of caching flavour. This is abstracted due to the interfaces ICacheProvider and ICacheManager. ICacheProvider takes care of the concrete cache implementation, ICacheManager is the read/write interface.

The convention is to adapt a concrete ICacheProvider implementation.

>>> from bda.cache import ICacheManager
>>> from bda.cache import Memcached
>>> provider = Memcached(['127.0.0.1:11211'])
>>> manager = ICacheManager(provider)

We can ask the manager for data inside the cache

>>> data = manager.get('somekey', force_reload=False)

If force_reload is set to True, try to delete data with key from cache and return None.

We’re also able to manipulate the cache’s data (some restrictions my result out of backend not providing them)

>>> manager.set('somekey', object())

There exist a convenience to use some API’s and cache it’s results all at once.

>>> data = manager.getData(func, key, force_reload=False, args=[], kwargs={})

First the data for key is looked up inside the cache provider. If not found there or if force_reload is set to True, call given func . The return value of this function will be stored in the cache provider. args and kwargs are passed as parameters to given function if it’s call is required.

You might ask why all this is done due to 2 seperate interfaces…

Some usecase might require different cache providers i.e. for different payload size. This way you can implement any other cache provider usage as well due to the cache manager interface.

Dependencies

  • zope.interface

  • zope.component

  • bda.cache.fscache.FSCache recommends that availability of cpickle

  • bda.memcached.Memcached requires python-memcached

Notes

If you’re interessted to contribute; Feel free but keep in mind that this code is planned to be released under a BSD like licence in future.

Changes

  • 1.1 (rnix, 2009-02-09):
    • Cache Managers are now adapters.

    • Implement memcached server support

    • deprecate the default CacheManager

    • Fix tests for FSCache

  • <= 1.0 (rnix):
    • Initial work

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

bda.cache-1.1.tar.gz (12.3 kB view details)

Uploaded Source

File details

Details for the file bda.cache-1.1.tar.gz.

File metadata

  • Download URL: bda.cache-1.1.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for bda.cache-1.1.tar.gz
Algorithm Hash digest
SHA256 73c597b623ada42dcf82fa969abfe9c4a57694ecaed53e5251b53afde8d38ec4
MD5 63aa97c100d2d4f243877f2ac48c16e1
BLAKE2b-256 2710ad62a1886b6ac66dc5026a745e96ab29f5ad73c858e51bdda9673ad5d1f1

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