Class TextCache

class ooodev.utils.cache.file_cache.TextCache(tmp_dir='', lifetime=-1)[source]

Bases: CacheBase

Caches files and retrieves cached files. Cached file are in a subfolder of system tmp dir.

__init__(tmp_dir='', lifetime=-1)

Constructor

Parameters:
  • tmp_dir (str, optional) – Dir name to create in tmp folder. Defaults to ‘ooo_uno_tmpl’.

  • lifetime (float) – Time in seconds that cache is good for.

Return type:

None

get(filename)[source]

Fetches file contents from cache if it exist and is not expired

Parameters:

filename (Union[str, Path]) – File to retrieve

Returns:

File contents if retrieved; Otherwise, None

Return type:

Union[str, None]

put(filename, content)[source]

Saves file contents into cache

Parameters:
  • filename (Union[str, Path]) – filename to write.

  • content (str) – Contents to write into file.

remove(filename)

Deletes a file from cache if it exist

Parameters:

filename (Union[str, Path]) – file to delete.

Return type:

None

property can_expire: bool

Gets/Sets cache expiration

Return type:

bool

property logger: NamedLogger

Gets logger

Return type:

NamedLogger

property path: Path

Gets cache path

Return type:

Path

property path_settings: ThePathSettingsComp

Gets path settings

Return type:

ThePathSettingsComp

property seconds: float

Gets/Sets cache time in seconds

Return type:

float