{
    "server": "gunicorn",
    "workers": 10,
    "log": null,
    "loglevel": "info",
    "accesslog": null,
    "host": "localhost",
    "port": 8080,
    "debug": false,
    "profile": "profile.json",
    "colormaps": "colormaps",
    "cache": {
        "driver": "htree",
        "chunk": "128MB",
        "size": "4GB",
        "src": "cache/chunks/{'%02d'%bits}:{hash}.tiles",
        "index": "cache/index.sqlite",
        "lock": "cache/.lock",
        "key": "{layer}/{zoom}/{x},{z};{sha1(colormap)}",
        "hashlen": 5,
        "select": "SELECT raw_data, modified from tiles WHERE layer={layer} AND zoom={zoom} AND x={x} AND z={z} AND colormap={sha1(colormap)}",
        "insert": "INSERT OR REPLACE INTO tiles (_id, _hash, layer, zoom, x, z, colormap, modified, raw_data) VALUES ({_id}, {_hash}, {layer}, {zoom}, {x}, {z}, {sha1(colormap)}, strftime('%s'), {raw_data})",
        "init": [
            "CREATE TABLE tiles (_id INT, _hash TEXT, layer TEXT, zoom INT, x INT, z INT, colormap TEXT, modified INT, raw_data BLOB)",
            "CREATE UNIQUE INDEX tiles_idx ON tiles (layer, zoom, x, z, colormap)",
            "CREATE INDEX tiles_modified_idx ON tiles (modified)"
        ]
    },
    "storage": [
        {
            "requires": ["layer", "zoom", "x", "z"],
            "driver": "sqlite",
            "src": "layers/{layer}/{zoom}/{x-x%100000}.tiles",
            "select": "SELECT raw_data, modified from tiles WHERE x={x} AND z={z}",
            "insert": "INSERT OR REPLACE INTO tiles (x, z, raw_data, modified) VALUES ({x}, {z}, {raw_data}, strftime('%s'))",
            "init": [
                "CREATE TABLE tiles (x INT, z INT, raw_data BLOB, modified INT)",
                "CREATE UNIQUE INDEX tiles_idx ON tiles (x, z)",
                "CREATE INDEX tiles_modified_idx ON tiles (modified)"
            ]
        },
        {
            "requires": ["layer", "zoom", "x", "z", "format"],
            "src": "layers/{layer}/{zoom}/{x},{z}.{format}"
        },
        {
            "requires": ["layer", "format"],
            "src": "layers/{layer}.{format}"
        }
    ]
}
