Camel.DataCache¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/c/en |
|||
r/w/c/en |
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent |
r |
Class Details¶
- class Camel.DataCache(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
- classmethod new(path)¶
- Parameters:
path (
str
) – Base path of cache, subdirectories will be created here.- Raises:
- Returns:
A new cache object, or
None
if the base path cannot be written to.- Return type:
Create a new data cache.
- add(path, key)¶
- Parameters:
- Raises:
- Returns:
a
Gio.IOStream
for the new cache item, orNone
on error- Return type:
Add a new item to the cache, returning a
Gio.IOStream
to the new item.The key and the path combine to form a unique key used to store the item.
Potentially, expiry processing will be performed while this call is executing.
The returned
Gio.IOStream
is referenced for thread-safety and must be unreferenced withGObject.Object.unref
() when finished with it.
- clear(path)¶
- Parameters:
path (
str
) – Path to the (sub) cache the item exists in.
Clear cache’s content in path.
New in version 3.2.
- foreach_remove(path, func, *user_data)¶
- Parameters:
path (
str
) – Path to the (sub) cache the items exist infunc (
Camel.DataCacheRemoveFunc
) – a callback to call for each found file in the cache
Traverses the self sub-cache identified by path and calls func for each found file. If the func returns
True
, then the file is removed, ifFalse
, it’s kept in the cache.New in version 3.26.
- get(path, key)¶
- Parameters:
- Raises:
- Returns:
a
Gio.IOStream
for the requested cache item, orNone
on error- Return type:
Lookup an item in the cache. If the item exists, a
Gio.IOStream
is returned for the item. The stream may be shared by multiple callers, so ensure the stream is in a valid state through external locking.The returned
Gio.IOStream
is referenced for thread-safety and must be unreferenced withGObject.Object.unref
() when finished with it.
- get_expire_enabled()¶
- Returns:
Whether expire is enabled.
- Return type:
Gets whether expire of cache data is enabled.
This is a complementary property for
Camel.DataCache.set_expire_age
() andCamel.DataCache.set_expire_access
(), which allows to disable expiry without touching the two values. Having expire enabled, but not have set any of the two times, still behaves like not having expiry enabled.New in version 3.24.
- get_filename(path, key)¶
- Parameters:
- Returns:
The filename for a cache item
- Return type:
Lookup the filename for an item in the cache
New in version 2.26.
- get_path()¶
- Returns:
the path to the data cache
- Return type:
Returns the path to the data cache.
New in version 2.32.
- remove(path, key)¶
- Parameters:
- Raises:
- Returns:
0 on success, -1 on error
- Return type:
Remove/expire a cache item.
- set_expire_access(when)¶
- Parameters:
when (
int
) – Timeout for access, or -1 to disable access expiry.
Set the cache expiration policy for access times.
Items in the cache which haven’t been accessed for when seconds may be expired at any time. Items are expired in a lazy manner, so it is indeterminate when the items will physically be removed.
Note you can set both an age and an access limit. The age acts as a hard limit on cache entries.
- set_expire_age(when)¶
- Parameters:
when (
int
) – Timeout for age expiry, or -1 to disable.
Set the cache expiration policy for aged entries.
Items in the cache older than when seconds may be flushed at any time. Items are expired in a lazy manner, so it is indeterminate when the items will physically be removed.
Note you can set both an age and an access limit. The age acts as a hard limit on cache entries.
- set_expire_enabled(expire_enabled)¶
- Parameters:
expire_enabled (
bool
) – a value to set
Sets whether expire of cache data is enabled.
This is a complementary property for
Camel.DataCache.set_expire_age
() andCamel.DataCache.set_expire_access
(), which allows to disable expiry without touching the two values. Having expire enabled, but not have set any of the two times, still behaves like not having expiry enabled.New in version 3.24.
Property Details¶
- Camel.DataCache.props.expire_enabled¶