CacheConfig#

class geodesic.boson.CacheConfig(enabled=False, ttl=None, **kwargs)[source]#

Cache Configuration.

This tells Boson how it should cache data from the provider.

There are two main options that can be controled here:

enabled: whether or not to cache data in the persistent cache. This is typically configured

to be cloud storage like S3 or GCS. Whether enabled is True or not, Boson will perform some level of internal caching, but the cache will not be backed by a persistent store unless this is set to True.

ttl: time to live for cached items in seconds. For quickly changing data, this should be set

to a low value. This defaults to 5 minutes if not set. If this value is greater than the default TTL of the internal cache (5 minutes), this TTL will only correspond to the persistent cache. If the value is less than the internal cache, the internal cache will use a TTL less than or equal to this value. If enabled is False and this value is set to a value greater than 5 minutes, Boson will cap the TTL at 5 minutes.

Parameters:
  • enabled (bool) – enable/disable persistent caching for a particular provider.

  • ttl (Union[datetime.timedelta, int, float]) – time to live for cached items in seconds. For quickly changing data, this should be set to a low value. Default is 5 minutes if not set.

Attributes

enabled

(bool) - enable/disable caching for a particular provider

ttl_seconds

(float) - time to live for cached items in seconds

Methods

clear()

copy()

fromkeys([value])

Create a new dictionary with keys from iterable and values set to value.

get(key[, default])

Return the value for key if key is in the dictionary, else default.

items()

keys()

pop(k[,d])

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem()

Remove and return a (key, value) pair as a 2-tuple.

setdefault(key[, default])

Insert key with a value of default if key is not in the dictionary.

update(*mapping, **kwargs)

values()