The client for remote calendars with builtin cache support
When you have a service that periodically runs, and you don't want to fetch a new version of your calendar each time, this is the go-to place.
CacheClient
A iCalendar client which takes care of caching the result for you. This avoids you needing to handle the caching.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cache_location |
Union[Path, str]
|
A path to the cache. Can be relative or absolute references. When you pass in a value with a file extension, it is considered to be a directory, otherwise it's considered as a file reference. |
required |
cache_ttl |
Union[Duration]
|
The time-to-live for the cache. The cache will be deleted/refreshed once it is older than the TTL. |
Duration(hours=1)
|
verbose |
bool
|
Print verbose messages regarding cache usage. |
True
|
url |
str
|
The URL to the iCalendar file. |
required |
Source code in ical_library/cache_client.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
cache_file_path: Path
property
Return the filepath to the cache for the given URL.
_is_cache_expired()
Return whether the cache is passed its expiration date.
Source code in ical_library/cache_client.py
82 83 84 85 86 |
|
_purge_icalendar_cache()
Purge the cache we have for this Calendar.
Source code in ical_library/cache_client.py
76 77 78 79 80 |
|
_write_response_to_cache(text)
Write the response of the fetched URL to cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str
|
The fetched result. |
required |
Source code in ical_library/cache_client.py
65 66 67 68 69 70 71 72 73 74 |
|
get_icalendar(**kwargs)
Get a parsed VCalendar instance. If there is an active cache, return that, otherwise fetch and cache the result.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kwargs |
Any
|
Any keyword arguments to pass onto the |
{}
|
Returns:
Type | Description |
---|---|
VCalendar
|
a VCalendar instance with all it's iCalendar components like VEvents, VToDos, VTimeZones etc. |
Source code in ical_library/cache_client.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|