zooui.tilesystem.tilestore.tilecache module¶
Thread-safe Least Recently Used (LRU) cache for storing tiles.
- class zooui.tilesystem.tilestore.tilecache.TileCache(maxsize=256, maxage=60)[source]¶
Bases:
object- Constructor:
TileCache(maxsize, maxage)
- Parameters :
maxsize : int maxage : int
TileCache(maxsize, maxage) –> None
TileCache objects are used for caching tiles in memory.
Tiles can be accessed in much the same way as dict objects: tilecache[tile_id] holds the tile identified by the given tile_id.
- Constructor:
TileCache(maxsize, maxage)
- Parameters :
maxsize : int maxage : int
TileCache(maxsize, maxage) –> None
Create a new TileCache object.
The maximum number of tiles to store is set by maxsize. There will be no limit if maxsize <= 0.
The maximum age of the tiles (in seconds) allowed before they are discarded is set by maxage. There will be no limit if maxage <= 0.
None tiles and (0,0,0) tiles do not count towards the number of stored tiles and will therefore not be automatically discarded.
- insert(tile_id, tile, maxaccesses=0)[source]¶
- Method :
TileCache.insert(tile_id, tile, maxaccesses)
- Parameters :
tile_id : Tuple[str, int, int, int] tile : Any maxaccesses : int
TileCache.insert(tile_id, tile, maxaccesses) –> None
Insert the tile with the given tile_id into the cache.
If maxaccesses <= 0, then the behaviour is the same as tilecache[tile_id]=tile. Otherwise the tile is set to expire after it has been accessed maxaccesses times.
- __mortal(tile_id, tile)¶
- Method :
__mortal(tile_id, tile)
- Parameters :
tile_id : Tuple[str, int, int, int] tile : Any
__mortal(tile_id, tile) –> bool
Returns a bool indicating whether the given tile is mortal.
The tile will never be removed from the cache if it is immortal.
None tiles and (0,0,0) tiles are the only ones considered immortal.
- __periodic_clean()¶
- Method :
__periodic_clean()
- Parameters :
None
__periodic_clean() –> infinite loop
Periodically remove old tiles based on maxage.
- __clean()¶
- Method :
__clean()
- Parameters :
None
__clean() –> None
Remove the least recently used tiles based on maxsize.