Shumate.FileCache¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
|---|---|---|---|
r/w/co |
The directory of the cache |
||
r/w/co |
The key used when storing and retrieving tiles |
||
r/w/c |
The cache’s size limit (Mb) |
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class Shumate.FileCache(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
A cache that stores and retrieves tiles from the file system. It is mainly used by [class`TileDownloader`], but can also be used by custom data sources.
The cache will be filled up to a certain size limit. When this limit is reached, the cache can be purged, and the tiles that are accessed least are deleted.
- ETags
The cache can optionally store an ETag string with each tile. This is useful to avoid redownloading old tiles that haven’t changed (for example, using the HTTP If-None-Match header).
- classmethod new_full(size_limit, cache_key, cache_dir)¶
- Parameters:
- Returns:
a constructed
Shumate.FileCache- Return type:
Constructor of
Shumate.FileCache.
- get_cache_dir()¶
- Returns:
the directory
- Return type:
Gets the directory where the cache database is stored.
- get_cache_key()¶
- Returns:
the cache key
- Return type:
Gets the key used to store and retrieve tiles from the cache. Different keys can be used to store multiple tilesets in the same cache directory.
- get_tile_async(x, y, zoom_level, cancellable, callback, *user_data)¶
- Parameters:
x (
int) – the X coordinate of the tiley (
int) – the Y coordinate of the tilezoom_level (
int) – the zoom level of the tilecancellable (
Gio.CancellableorNone) – aGio.Cancellablecallback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallbackto execute upon completion
Gets tile data from the cache, if it is available.
- get_tile_finish(result)¶
- Parameters:
result (
Gio.AsyncResult) – aGio.AsyncResultprovided to callback- Raises:
- Returns:
a
GLib.Bytescontaining the tile data, orNoneif the tile was not in the cache or an error occurred- Return type:
(
GLib.Bytes, etag:strorNone, modtime:GLib.DateTimeorNone)
Gets the tile data from a completed
Shumate.FileCache.get_tile_async() operation.modtime will be set to the time the tile was added to the cache, or the latest time it was confirmed to be up to date.
etag will be set to the data’s ETag, if present.
- mark_up_to_date(x, y, zoom_level)¶
- Parameters:
Marks a tile in the cache as being up to date, without changing its data.
For example, a network source might call this function when it gets an HTTP 304 Not Modified response.
- purge_cache_async(cancellable, callback, *user_data)¶
- Parameters:
cancellable (
Gio.CancellableorNone) – aGio.Cancellablecallback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallbackto execute upon completion
Removes less used tiles from the cache, if necessary, until it fits in the size limit.
- purge_cache_finish(result)¶
- Parameters:
result (
Gio.AsyncResult) – aGio.AsyncResultprovided to callback- Raises:
- Returns:
- Return type:
Gets the result of an async operation started using
Shumate.FileCache.purge_cache_async().
- set_size_limit(size_limit)¶
- Parameters:
size_limit (
int) – the cache limit in bytes
Sets the cache size limit in bytes.
- store_tile_async(x, y, zoom_level, bytes, etag, cancellable, callback, *user_data)¶
- Parameters:
x (
int) – the X coordinate of the tiley (
int) – the Y coordinate of the tilezoom_level (
int) – the zoom level of the tilebytes (
GLib.Bytes) – aGLib.Bytescancellable (
Gio.CancellableorNone) – aGio.Cancellablecallback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallbackto execute upon completion
Stores a tile in the cache.
- store_tile_finish(result)¶
- Parameters:
result (
Gio.AsyncResult) – aGio.AsyncResultprovided to callback- Raises:
- Returns:
- Return type:
Gets the success value of a completed
Shumate.FileCache.store_tile_async() operation.
Property Details¶
- Shumate.FileCache.props.cache_dir¶
- Name:
cache-dir- Type:
- Default Value:
- Flags:
The directory where the tile database is stored.
- Shumate.FileCache.props.cache_key¶
- Name:
cache-key- Type:
- Default Value:
- Flags:
The key used to store and retrieve tiles from the cache. Different keys can be used to store multiple tilesets in the same cache directory.