TimedCache#

class wattson.util.performance.timed_cache.TimedCache(cache_refresh_callback: Callable, cache_timeout_seconds: float, set_initial_content: bool = False, initial_content: Any = None, async_refresh: bool = True)#

Bases: object

Methods

__init__

get_content

Returns the cache's content.

get_raw_content

Returns the cache's content.

is_refresh_required

is_up_to_date

set_outdated

__init__(cache_refresh_callback: Callable, cache_timeout_seconds: float, set_initial_content: bool = False, initial_content: Any = None, async_refresh: bool = True)#
get_content(*args, **kwargs) Any#

Returns the cache’s content. If the content is outdated, calls the refresh callback first.

Parameters:
  • *args

  • **kwargs

Returns:

The cache’s (updated) content

Return type:

Any

get_raw_content() Any#

Returns the cache’s content. This does not update the content.

Returns:

The cache’s (potentially outdated) content

Return type:

Any