silo.low_code.framework.caching module
- silo.low_code.framework.caching.cleanup_expired_udc(cache_mgr, metadata_key, metadata, sigkill_time)
Remove expired metadata entries
Remove any cached values that have expired related to this metadata. Only one process can perform the deletion at once to address potential race-condition issues.
- Parameters
cache_mgr (silo.apps.cache.CacheManager) – CacheManager responsible for removing the expired entries
metadata_key (str) – Key to the metadata field
metadata (list) – Metadata contained in the primary key
sigkill_time (int) – Time until a sigterm deletion should occur
- silo.low_code.framework.caching.read_cached_results(cache_key, reuse_for=None)
Return the most recent cached element for the given cache_key
This function enables the lookup of Snippet Framework cached elements outside of the Snippet Framework. While this function could work with automatic cache keys the Snippet Framework generates, its best used by overriding the cache_key name within the steps configuration.
The functionality of
reuse_for
operates the same way within the Snippet Framework. This value is specified in minutes before a cached entry is considered stale. If this value is specified, an entry is considered stale if the following criteria is met:\[collection\_time + reuse\_for <= current\_time\]If the newest entry is considered stale, the exception silo.apps.cache.CacheDataIsExpired will be raised.
If an invalid object is found (bad formatting within the cache), the exception
MetadataError
will be raised.- Parameters
cache_key (str) – Specified cache_key for the step
reuse_for (int) – Time (in seconds) before considering an entry as stale
- Return type
object
- silo.low_code.framework.caching.read_step_cache(step, reuse_for, metadata_key, gmtimestamp)
Check the cache for step data prior to step execution
- Parameters
step (int) – Number of the current step
reuse_for (int) – Cache use limit in seconds
metadata_key (str) – Current step request id or key hashed
gmtimestamp (int) – gmtimestamp of the current collection window
- Returns
Cached data if it exists, otherwise None
- silo.low_code.framework.caching.write_udc(cache_mgr, cache_config, gmtimestamp, metadata_key, value)
Updates the current metadata using a lock
- Parameters
cache_mgr (silo.apps.cache.CacheManager) – CacheManager responsible for removing the expired entries
cache_config (dict) – Cache configuration for the step
gmtimestamp (int) – epoch time when the collection will be stored
metadata_key (str) – Primary metadata key
value (object) – Value to cache