Package mapproxy :: Package core :: Module cache :: Class FileCache
[hide private]
[frames] | no frames]

Class FileCache

source code

object --+
         |
        FileCache

This class is responsible to store and load the actual tile data.
Instance Methods [hide private]
 
__init__(self, cache_dir, file_ext, pre_store_filter=None, link_single_color_images=False)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
level_location(self, level)
Return the path where all tiles for level will be stored.
source code
 
tile_location(self, tile, create_dir=False)
Return the location of the tile.
source code
 
_single_color_tile_location(self, color, create_dir=False) source code
 
timestamp_created(self, tile)
Return the timestamp of the last modification of the tile.
source code
 
_update_tile_metadata(self, tile) source code
 
is_cached(self, tile)
Returns True if the tile data is present.
source code
 
load(self, tile, with_metadata=False)
Fills the _Tile.source of the tile if it is cached.
source code
 
store(self, tile)
Add the given tile to the file cache.
source code
 
_store(self, tile, location) source code
 
__repr__(self)
repr(x)
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, cache_dir, file_ext, pre_store_filter=None, link_single_color_images=False)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Parameters:
  • cache_dir - the path where the tile will be stored
  • file_ext - the file extension that will be appended to each tile (e.g. 'png')
  • pre_store_filter - a list with filter. each filter will be called with a tile before it will be stored to disc. the filter should return this or a new tile object.
Overrides: object.__init__

tile_location(self, tile, create_dir=False)

source code 

Return the location of the tile. Caches the result as location property of the tile.

>>> c = FileCache(cache_dir='/tmp/cache/', file_ext='png')
>>> c.tile_location(_Tile((3, 4, 2))).replace('\\', '/')
'/tmp/cache/02/000/000/003/000/000/004.png'
Parameters:
  • tile - the tile object
  • create_dir - if True, create all necessary directories
Returns:
the full filename of the tile

load(self, tile, with_metadata=False)

source code 
Fills the _Tile.source of the tile if it is cached. If it is not cached or if the .coord is None, nothing happens.

store(self, tile)

source code 

Add the given tile to the file cache. Stores the _Tile.source to FileCache.tile_location.

All pre_store_filter will be called with the tile, before it will be stored.

__repr__(self)
(Representation operator)

source code 
repr(x)
Overrides: object.__repr__
(inherited documentation)