CacheConfiguration

public struct CacheConfiguration
extension CacheConfiguration: Equatable

Cache configuration for caching both tiles and styles.

It provides control over the system memory and disk capacity used for caching, as well as the maximum cache duration for style resources and a mapping of cache durations to corresponding request URL filters. Unlike style caching, the tiles’ cache duration is handled by the server, utilizing the max-age header.

Important

This is a Public Preview API. It may be changed or removed at any time.
  • Creates an instance of CacheConfiguration.

    If no parameters are provided, the CacheConfiguration will be initialized with the following default values: memoryCapacity: 5MB diskCapacity: 50MB duration: 24 hours cacheDurationFilter: [:]

    Declaration

    Swift

    public init(
        memoryCapacity: Measurement<UnitInformationStorage> = .init(value: 5, unit: .megabytes),
        diskCapacity: Measurement<UnitInformationStorage> = .init(value: 50, unit: .megabytes),
        duration: Measurement<UnitDuration> = .init(value: 24, unit: .hours),
        cacheDurationFilter: [String: Measurement<UnitDuration>] = [:]
    )

    Parameters

    memoryCapacity

    The caching capacity, in bytes, while caching the tiles to system memory.

    diskCapacity

    The caching capacity, in bytes, while caching the tiles and styles to disk.

    duration

    The maxium amount of time that a style fetched resource should be allowed to remain in cache.

    cacheDurationFilter

    Mapping of the data duration in cache to the corresponding request URL filter. For example: Request: https://api.tomtom.com/map/2/tile/basic/{z}/{x}/{y}.pbf Response: CacheControl = "maxAge=60" cacheDurationFilter = ["/tile/basic": .init(value: 120, unit: .seconds)] In this case, Response data will be stored in cache for 120 seconds instead of 60.

  • The caching capacity, in bytes, while caching the tiles to system memory.

    Declaration

    Swift

    public let memoryCapacity: Measurement<UnitInformationStorage>
  • The caching capacity, in bytes, while caching the tiles and styles to disk.

    Declaration

    Swift

    public let diskCapacity: Measurement<UnitInformationStorage>
  • The maximum amount of time that a style fetched resource should be allowed to remain in cache.

    Declaration

    Swift

    public let duration: Measurement<UnitDuration>
  • Mapping of the data duration in cache to the corresponding request URL filter.

    For example: Request: https://api.tomtom.com/map/2/tile/basic/{z}/{x}/{y}.pbf Response: CacheControl = "maxAge=60" cacheDurationFilter = ["/tile/basic": .init(value: 120, unit: .seconds)] In this case, Response data will be stored in cache for 120 seconds instead of 60.

    Declaration

    Swift

    public let cacheDurationFilter: [String : Measurement<UnitDuration>]