tiled.client.cache.Cache

class tiled.client.cache.Cache(capacity, *, url_to_headers_cache, etag_to_content_cache, global_lock, lock_factory, state, scorer=None)[source]

A client-side cache of data from the server.

The __init__ is to be used internally and by authors of custom caches. See Cache.in_memory() and Cache.on_disk() for user-facing methods.

This is used by the function tiled.client.utils.get_content_with_cache.

__init__(capacity, *, url_to_headers_cache, etag_to_content_cache, global_lock, lock_factory, state, scorer=None)[source]
Parameters:
capacityint

The number of bytes of data to keep in the cache

url_to_headers_cacheMutableMapping

Dict-like object to use for cache

etag_to_content_cacheMutableMapping

Dict-like object to use for cache

global_lockLock

A lock used for the url_to_headers_cache

lock_factorycallable

Expected signature: f(etag) -> Lock

stateobject

Namespace used for storing general-purpose cache state

scorer: Scorer, optional

A Scorer object that controls how we decide what to retire when space is low.

Methods

__init__(capacity, *, url_to_headers_cache, ...)

Parameters:

clear()

get_reservation(url)

in_memory(capacity, *[, scorer])

An in-memory cache of data from the server

on_disk(path[, capacity, scorer])

An on-disk cache of data from the server

put(url, headers, content)

renew(url, etag, expires)

resize(capacity)

Resize the cache.

retire(etag)

Retire/remove a etag from the cache

shrink([target])

Retire keys from the cache until we're under bytes budget

Attributes

when_full

Controls what happens the cache is at capacity