CacheManager
extension CacheManager
-
Construct a new cache manager.
Declaration
Swift
public convenience init(options: ResourceOptions)
Parameters
options
Resource fetching options to be used by the cache manager.
-
Forces a revalidation of the tiles in the ambient cache and downloads a fresh version of the tiles from the tile server.
This is more efficient than clearing the cache using
clearAmbientCache()
because tiles in the ambient cache are re-downloaded to remove outdated data from a device. It does not erase resources from the ambient cache or delete the database, which can be computationally expensive operations that may carry unintended side effects.Declaration
Swift
public func invalidateAmbientCache(_ completion: @escaping (Result<Void, Error>) -> Void)
Parameters
completion
Called once the request is complete or an error occurred.
-
Sets the maximum size of the ambient cache in bytes.
This call is potentially expensive because it will try to trim the data in case the database is larger than the size defined. Setting the size to 0 will effectively disable the cache. Preferably, this method should be called before using the database, otherwise the default maximum size will be used.
Declaration
Swift
public func setMaximumAmbientCacheSize(_ size: UInt64, completion: @escaping (Result<Void, Error>) -> Void)
Parameters
size
The maximum size of the ambient cache in bytes.
completion
Called once the request is complete or an error occurred.
-
Erase resources from the ambient cache, freeing storage space.
This operation can be potentially slow Compared to \c invalidateAmbientCache() because it will trigger a VACUUM on SQLite, forcing the database to move pages on the filesystem.
Declaration
Swift
public func clearAmbientCache(_ completion: @escaping (Result<Void, Error>) -> Void)
Parameters
completion
Called once the request is complete or an error occurred.
-
Sets path of a database to be used by the ambient cache and invokes provided callback when a database path is set.
Declaration
Swift
public func setDatabasePath(_ path: String, completion: @escaping (Result<Void, Error>) -> Void)
Parameters
path
The new database path
completion
Callback to call once the request is completed or an error occurred.
-
Prefetches the resources for the from network and populates the ambient cache.
Declaration
Swift
public func prefetchAmbientCache(for cacheArea: CacheAreaDefinition, completion: @escaping (Result<Void, Error>) -> Void) -> Cancelable
Parameters
cacheArea
Map area to pre-fetch and put into ambient cache
completion
Callback to call once the request is completed or an error occurred.
Return Value
Returns a Cancelable object to cancel the load request