Skip to main content

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.cache.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.3.0 (2019-02-05)

  • Python 3 comaptibility [reinhardt]

  • Code style (black/isort) [jensens]

1.2.0 (2017-10-19)

  • Change to use libmc or pylibmc when available

  • Add option to require with bda.cache[pylibmc] or bda.cache[libmc]

1.1.2 (2009-02-10)

  • remove legacy code

1.1.1 (2009-02-10)

  • bugfix in zcml configuration.

1.1 (2009-02-09)

  • Cache Managers are now adapters.

  • Implement memcached server support

  • deprecate the default CacheManager

  • Fix tests for FSCache

1.0

  • Initial work

Release files for bda.cache 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bda.cache 1.3.0
File Size Uploaded
bda.cache-1.3.0.tar.gz 11.1 kB Details

Release files / bda.cache-1.3.0.tar.gz

Download URL bda.cache-1.3.0.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
969424ee1cd8b5fe2a159cb72598b8b711eb0b924e688b0b17a3716cec56cbf1
BLAKE2b-256 checksum
How to use checksums
34211fb049d0dc291efb927d1df0ff9c345fd0c529f2e4f114a5d42ec501a636
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

Release history Release notifications | RSS feed

This release

1.3.0 This release

1 release file

1.2.0

1 release file

1.1.3

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page