TileStache.Goodies.Caches.LimitedDisk module

Cache that stores a limited amount of data.

This is an example cache that uses a SQLite database to track sizes and last-read times for cached tiles, and removes least-recently-used tiles whenever the total size of the cache exceeds a set limit.

Example TileStache cache configuration, with a 16MB limit:

“cache”: {

“class”: “TileStache.Goodies.Caches.LimitedDisk.Cache”, “kwargs”: {

“path”: “/tmp/limited-cache”, “limit”: 16777216

}

}

class TileStache.Goodies.Caches.LimitedDisk.Cache(path, limit, umask=18)
lock(layer, coord, format)

Acquire a cache lock for this tile.

Returns nothing, but (TODO) blocks until the lock has been acquired. Lock is implemented as a row in the “locks” table.

read(layer, coord, format)

Read a cached tile.

If found, update the used column in the tiles table with current time.

remove(layer, coord, format)

Remove a cached tile.

save(body, layer, coord, format)
unlock(layer, coord, format)

Release a cache lock for this tile.

Lock is implemented as a row in the “locks” table.