cache#
- Handles all caching logic including:
Retrieving from cache
Saving to cache
Determining whether not certain items have expired and need to be refreshed
Functions#
|
|
|
This checks the contents of the cache response to see if it is expired. |
|
Returns the location of the notices cache directory as a Path object |
|
Return path of notices cache |
Retrieves a notice response object from cache if it exists. |
|
|
Writes our notice data to our local cache location. |
|
Insert channel notice into our database marking it as read. |
|
Return the ids of the channel notices which have already been seen. |
|
Invalidate the notices cache so notices will be retrieved and displayed |
Attributes#
- logger#
- cached_response(func)#
- is_notice_response_cache_expired(channel_notice_response: conda.notices.types.ChannelNoticeResponse) bool#
This checks the contents of the cache response to see if it is expired.
If for whatever reason we encounter an exception while parsing the individual messages, we assume an invalid cache and return true.
- get_notices_cache_dir() pathlib.Path#
Returns the location of the notices cache directory as a Path object
- get_notices_cache_file() pathlib.Path#
Return path of notices cache
If the file does not exist, we create it with natural filesystem timestamps, then set only the modification time to be in the past. This ensures notices are checked and displayed immediately rather than waiting for the full display interval.
- get_notice_response_from_cache(url: str, name: str, cache_dir: pathlib.Path) conda.notices.types.ChannelNoticeResponse | None#
Retrieves a notice response object from cache if it exists.
- write_notice_response_to_cache(channel_notice_response: conda.notices.types.ChannelNoticeResponse, cache_dir: pathlib.Path) None#
Writes our notice data to our local cache location.
- mark_channel_notices_as_viewed(cache_file: pathlib.Path, channel_notices: collections.abc.Sequence[conda.notices.types.ChannelNotice]) None#
Insert channel notice into our database marking it as read.
- get_viewed_channel_notice_ids(cache_file: pathlib.Path, channel_notices: collections.abc.Sequence[conda.notices.types.ChannelNotice]) set[str]#
Return the ids of the channel notices which have already been seen.
- clear_cache() None#
Invalidate the notices cache so notices will be retrieved and displayed on the next command invocation.
For the
notices.cachefile we rewind its mtime into the past instead of removing it. On Windows the file can be transiently locked (e.g. by antivirus or lingering file handles), in which caseunlink()raisesPermissionErrorand the cache would otherwise remain with a recenttouch()-ed mtime, suppressing notices on subsequent runs.Per-channel cached response files are still removed when possible, but any
OSErrorraised while unlinking them is ignored for the same reason.