The cache module

Cache logic.

class ImageEntry(image)[source]

Bases: object

class ImageCache[source]

Bases: object

Cache generated images.

Store and retrieve them under a key (see render.Renderer.key()).

maxsize = 209715200
currentsize = 0
clear()[source]

Remove all cached images.

invalidate(page)[source]

Clear cache contents for the specified page.

tileset(key)[source]

Return a dictionary with tile-entry pairs for the key.

If no single tile is available, an empty dict is returned.

prepare(tiles)[source]

Make room before rendering new tiles.

This ensures there is space for the new tiles by adjusting the cache size and/or purging older images as needed.

addtile(key, tile, image)[source]

Add image for the specified key and tile.

purge(reservedsize=0)[source]

Purge old images if needed.

At least reservedsize bytes will remain available.

closest(key)[source]

Iterate over suitable image tilesets but with a different size.

Yields (width, height, tileset) tuples.

This can be used for interim display while the real image is being rendered.