Caching
PeterCache
This class provides methods to interact with the cache for the Peter Explains CLI.
Source code in peter_explains/cache.py
__contains__(key)
Check if the cache contains a specific key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
The key to check. |
required |
Returns:
Type | Description |
---|---|
True if the cache contains the key, False otherwise. |
__init__()
clear()
delete(key)
Deletes the specified key from the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
The key to be deleted from the cache. |
required |
Returns:
Type | Description |
---|---|
None |
get(key)
Retrieve the value associated with the given key from the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
any
|
The key to retrieve the value for. |
required |
Returns:
Type | Description |
---|---|
CommandExplanation | CommandExplanationWithArguments | None
|
The value associated with the key, or None if the key is not found. |
Source code in peter_explains/cache.py
get_cache_dir(cache_dir_name)
staticmethod
This function gets the cache directory for the Peter Explains CLI based on the operating system.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cache_dir_name |
str
|
The name of the Peter Explains CLI cache directory. |
required |
Returns:
Name | Type | Description |
---|---|---|
cache_dir |
str
|
The cache directory for the Peter Explains CLI. |
Source code in peter_explains/cache.py
save(key, value)
Saves the given value in the cache with the specified key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The key to associate with the value in the cache. |
required |
value |
CommandExplanation | CommandExplanationWithArguments
|
The value to be saved in the cache. |
required |
Returns:
Type | Description |
---|---|
None |