pip_services3_components.cache.ICache module

pip_services3_components.cache.ICache

Interface for caching components.

copyright

Conceptual Vision Consulting LLC 2018-2019, see AUTHORS for more details.

license

MIT, see LICENSE for more details.

class pip_services3_components.cache.ICache.ICache

Bases: abc.ABC

Interface for caches that are used to cache values to improve performance.

remove(correlation_id: Optional[str], key: str)

Removes a value from the cache by its key.

Parameters
  • correlation_id – (optional) transaction id to trace execution through call chain.

  • key – a unique value key.

retrieve(correlation_id: Optional[str], key: str) → Any

Retrieves cached value from the cache using its key. If value is missing in the cache or expired it returns None.

Parameters
  • correlation_id – (optional) transaction id to trace execution through call chain.

  • key – a unique value key.

Returns

a cached value or None if value wasn’t found or timeout expired.

store(correlation_id: Optional[str], key: str, value: Any, timeout: int) → Any

Stores value in the cache with expiration time.

Parameters
  • correlation_id – (optional) transaction id to trace execution through call chain.

  • key – a unique value key.

  • value – a value to store.

  • timeout – expiration timeout in milliseconds.

Returns

a cached value stored in the cache.