python.external_config.file_cache module¶
-
delete_cache
(*args, **kwargs)[source]¶ Deletes a cache given its identifier. If no cache file exists, nothing is executed.
Parameters: identifier_dict (dict) – Dictionary of identifying data.
-
get_cache_path
(identifier_dict)[source]¶ Create a file name given a dictionary of identifiers, e.g.
{shot: 123, project: 345}
etc. A hash value will be computed based on the identifier and used to determine the path. The current user will be added to the hash in order to make it user-centric.If the hash key ‘prefix’ is detected, this will be added to the path as a parent folder to the cache file. This provides a simple way to organize different caches into different folders.
Parameters: identifier_dict (dict) – Dictionary of identifying data. Retuns: path on disk, relative to the current bundle’s cache location.
-
load_cache
(identifier_dict)[source]¶ Loads a cache from disk given a dictionary of identifiers, e.g.
{shot: 123, project: 345}
etc. A hash value will be computed based on the identifier and used to find and load a cached payload.Parameters: identifier_dict (dict) – Dictionary of identifying data. Returns: Cached data as generated by write_cache()
.
-
load_cache_file
(*args, **kwargs)[source]¶ Loads a cache from disk given a file path generated by
get_cache_path()
. If the file is not found,None
is returned.Parameters: cache_path (str) – Path to a cache file on disk. Returns: Cached data as generated by write_cache()
orNone
if file is not found.
-
write_cache
(identifier_dict, data)[source]¶ Writes cache data to disk given a dictionary of identifiers, e.g.
{shot: 123, project: 345}
etc. A hash value will be computed based on the identifier and used to determine the location for where the cache file will be savedParameters: - identifier_dict (dict) – Dictionary of identifying data.
- data – Data to save.
-
write_cache_file
(*args, **kwargs)[source]¶ Writes a cache to disk given a file path generated by
get_cache_path()
.Parameters: - path (str) – Path to a cache file on disk.
- data – Data to save.