File Cache
FileCache
Bases: CacheStrategy
Cache data and settings as separate files.
We store the cached files in a separate folder in the CKAN storage.
generate_unique_consistent_filename(key)
Generate unique and consistent filename based on the key.
PARAMETER | DESCRIPTION |
---|---|
key
|
The cache key to generate the filename.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
The filename. |
get_data(key)
Return data and settings from cache if exists.
PARAMETER | DESCRIPTION |
---|---|
key
|
The cache key to retrieve the data.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ChartData | None
|
ChartData or None if not found. |
get_meta_path(file_path)
Return the metadata file path for a given file.
PARAMETER | DESCRIPTION |
---|---|
file_path
|
The original file path.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
The corresponding .meta file path. |
invalidate(key)
Remove data from cache.
PARAMETER | DESCRIPTION |
---|---|
key
|
The cache key to invalidate.
TYPE:
|
is_file_cache_expired(file_path)
staticmethod
Check if file cache is expired.
PARAMETER | DESCRIPTION |
---|---|
file_path
|
The path to the file.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
bool
|
True if file cache is expired, otherwise False. |
make_file_path_from_key(key)
Generate file path based on the key
PARAMETER | DESCRIPTION |
---|---|
key
|
The cache key to generate the file path.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
The file path. |
read_data(file, file_path)
abstractmethod
Read cached data and settings from a file object.
PARAMETER | DESCRIPTION |
---|---|
file
|
The file object to read the data.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ChartData | None
|
ChartData or None if not found. |
read_metadata(file_path)
Read metadata from a .meta file if it exists.
PARAMETER | DESCRIPTION |
---|---|
file_path
|
The original file path.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict[str, Any]
|
The metadata if it exists, otherwise None. |
set_data(key, data)
Store data and settings to cache.
PARAMETER | DESCRIPTION |
---|---|
key
|
The cache key to store the data.
TYPE:
|
data
|
The ChartData to be stored.
TYPE:
|
write_data(file_path, data)
abstractmethod
Defines how to write data and settings to a file.
PARAMETER | DESCRIPTION |
---|---|
file_path
|
The path to the file.
TYPE:
|
data
|
The ChartData to be stored.
TYPE:
|
write_metadata(file_path, data)
Write metadata to a .meta file if settings and columns are provided.
PARAMETER | DESCRIPTION |
---|---|
file_path
|
The original file path.
TYPE:
|
data
|
The metadata to store.
TYPE:
|
FileCacheORC
Bases: FileCache
Cache data as ORC file
read_data(file, file_path)
Read cached data from an ORC file and settings from .meta file.
PARAMETER | DESCRIPTION |
---|---|
file
|
The file object to read the data.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ChartData | None
|
ChartData or None if not found. |
write_data(file_path, data)
Write data to an ORC file and store settings in a separate .meta file.
PARAMETER | DESCRIPTION |
---|---|
file_path
|
The path to the file.
TYPE:
|
data
|
The ChartData to be stored.
TYPE:
|
FileCacheCSV
Bases: FileCache
Cache data as CSV file
read_data(file, file_path)
Read cached data from a CSV file and settings from .meta file.
PARAMETER | DESCRIPTION |
---|---|
file
|
The file object.
TYPE:
|
file_path
|
The original file path.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ChartData | None
|
ChartData or None if not found. |
write_data(file_path, data)
Write data to a CSV file and optionally write settings metadata.
PARAMETER | DESCRIPTION |
---|---|
file_path
|
The path to the file.
TYPE:
|
data
|
The ChartData to be stored.
TYPE:
|