Cache
OtfCache ¶
Bases: Cache
Small wrapper around diskcache.Cache to handle OTF API specific caching.
This class provides methods to write and read device data and token data to/from the cache. It also provides methods to clear the cache and specific tags.
write_device_data_to_cache ¶
write_device_data_to_cache(device_data)
Writes device data to the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device_data
|
dict[str, str]
|
The device data to write to the cache. |
required |
read_device_data_from_cache ¶
read_device_data_from_cache()
Reads device data from the cache.
Returns:
| Type | Description |
|---|---|
dict[str, str | None]
|
dict[str, str]: The device data read from the cache. |
write_token_data_to_cache ¶
write_token_data_to_cache(token_data, expiration=None)
Writes token data to the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token_data
|
dict[str, str]
|
The token data to write to the cache. |
required |
expiration
|
int | None
|
The expiration time in seconds for the cache entry. Defaults to None. |
None
|
read_token_data_from_cache ¶
read_token_data_from_cache()
Reads token data from the cache.
Returns:
| Type | Description |
|---|---|
dict[str, str | None]
|
dict[str, str | None]: The token data read from the cache. |
get_cache_dir ¶
get_cache_dir()
Returns the cache directory for the OTF API.
The cache directory is based on the version of the OTF API package.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The cache directory path. |