'Initialize the Monkeycache Provider.
Cache_config is a complete cache configuration dictionary that you
might use in a TileStache setup (http://tilestache.org/doc/#caches).
This is where Monkeycache will look for already-rendered tiles.
Layer_name is the name of a layer saved in that cache.
Format should match the second return value of your original
layer\'s getTypeByExtention() method, e.g. "PNG", "JPEG", or for
the Vector provider "GeoJSON" and others. This might not necessarily
match the file name extension, though common cases like "jpg"/"JPEG"
are accounted for.'

def __init__(self, layer, cache_config, layer_name, format='PNG'):

    fake_layer_dict = {'provider': {'name': 'Proxy', 'url': 'http://localhost/{Z}/{X}/{Y}.png'}}
    fake_config_dict = {'cache': cache_config, 'layers': {layer_name: fake_layer_dict}}
    fake_config = buildConfiguration(fake_config_dict, layer.config.dirpath)
    self.source_layer = fake_config.layers[layer_name]
    self.source_cache = fake_config.cache
    formats = dict(png='PNG', jpg='JPEG', jpeg='JPEG')
    self.tile_format = formats.get(format.lower(), format)
