<commit_before>Caches
######

.. versionadded:: 1.2.0

MapProxy supports multiple backends to store the internal tiles. The default backend is file based and does not require any further configuration.

Configuration
=============

You can configure a backend for each cache with the ``cache`` option.
Each backend has a ``type`` and one or more options.

::

  caches:
    mycache:
      sources: [...]
      grids: [...]
      cache:
        type: backendtype
        backendoption1: value
        backendoption2: value
        

The following backend types are available.

``file``
========

This is the default cache type and it uses a single file for each tile. Available options are:

``directory_layout``:
  The directory layout MapProxy uses to store tiles on disk. Defaults to ``tc`` which uses a TileCache compatible directory layout (``zz/xxx/xxx/xxx/yyy/yyy/yyy.format``). ``tms`` uses TMS compatible directories (``zz/xxxx/yyyy.format``).

  .. note:: 
    ``tms`` layout is not suited for large caches, since it will create directories with thousands of files, which most file systems do not handle well.


``mbtiles``
===========

Use a single SQLite file for this cache. It uses the `MBTile specification <http://mbtiles.org/>`_.

Available options:

``filename``:
  The path to the MBTiles file. Defaults to ``cachename.mbtiles``.


You can set the ``sources`` to an empty list, if you use an existing MBTiles file and do not have a source.

::

  caches:
    mbtiles_cache:
      sources: []
      grids: [GLOBAL_MERCATOR]
      cache:
        type: mbtiles
        filename: /path/to/bluemarble.mbtiles

.. note::

  The MBTiles format specification does not include any timestamps for each tile and the seeding function is limited therefore. If you include any ``refresh_before`` time in a seed task, all tiles will be recreated regardless of the value. The cleanup process does not support any ``remove_before`` times for MBTiles and it always removes all tiles.
  Use the ``--summary`` option of the ``mapproxy-seed`` tool.

``couchdb``
===========

.. versionadded:: 1.3.0

Store tiles inside a `CouchDB <http://couchdb.apache.org/>`_. MapProxy creates a JSON document for each tile. This document contains metadata, like timestamps, and the tile image itself as a attachment.<commit_msg>add requirements to couchdb documentation<commit_after>Caches
######

.. versionadded:: 1.2.0

MapProxy supports multiple backends to store the internal tiles. The default backend is file based and does not require any further configuration.

Configuration
=============

You can configure a backend for each cache with the ``cache`` option.
Each backend has a ``type`` and one or more options.

::

  caches:
    mycache:
      sources: [...]
      grids: [...]
      cache:
        type: backendtype
        backendoption1: value
        backendoption2: value
        

The following backend types are available.

``file``
========

This is the default cache type and it uses a single file for each tile. Available options are:

``directory_layout``:
  The directory layout MapProxy uses to store tiles on disk. Defaults to ``tc`` which uses a TileCache compatible directory layout (``zz/xxx/xxx/xxx/yyy/yyy/yyy.format``). ``tms`` uses TMS compatible directories (``zz/xxxx/yyyy.format``).

  .. note:: 
    ``tms`` layout is not suited for large caches, since it will create directories with thousands of files, which most file systems do not handle well.


``mbtiles``
===========

Use a single SQLite file for this cache. It uses the `MBTile specification <http://mbtiles.org/>`_.

Available options:

``filename``:
  The path to the MBTiles file. Defaults to ``cachename.mbtiles``.


You can set the ``sources`` to an empty list, if you use an existing MBTiles file and do not have a source.

::

  caches:
    mbtiles_cache:
      sources: []
      grids: [GLOBAL_MERCATOR]
      cache:
        type: mbtiles
        filename: /path/to/bluemarble.mbtiles

.. note::

  The MBTiles format specification does not include any timestamps for each tile and the seeding function is limited therefore. If you include any ``refresh_before`` time in a seed task, all tiles will be recreated regardless of the value. The cleanup process does not support any ``remove_before`` times for MBTiles and it always removes all tiles.
  Use the ``--summary`` option of the ``mapproxy-seed`` tool.

``couchdb``
===========

.. versionadded:: 1.3.0

Store tiles inside a `CouchDB <http://couchdb.apache.org/>`_. MapProxy creates a JSON document for each tile. This document contains metadata, like timestamps, and the tile image itself as a attachment.


Requirements
------------

Besides a running CouchDB you will need the `Python requests package <http://python-requests.org/>`_. You can install it the usual way, for example ``pip install requests``.

Configuration
-------------
{'fraction_non_alphanumeric': 0.11102007374027038, 'fraction_numerical': 0.0032773453502662844, 'mean_word_length': 3.4921803127874886, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5580814', 'n_tokens_mistral': 1370, 'n_tokens_neox': 1330, 'n_words': 613}