<commit_before>.. _cache:

Caching Backends
================
PyPICloud stores the packages in a storage backend (typically S3), but that backend
is not necessarily efficient for frequently reading metadata. So instead of
hitting S3 every time we need to find a list of package versions, we store all
that metadata in a cache. The cache does not have to be backed up because it is
only a local cache of data that is permanently stored in the storage backend.

SQLAlchemy
----------
Set ``pypi.db = sql`` OR ``pypi.db = pypicloud.cache.SQLCache`` OR leave it out
completely since this is the default.

``db.url``
~~~~~~~~~~
**Argument:** string

The database url to use for the caching database. Should be a `SQLAlchemy url
<http://docs.sqlalchemy.org/en/rel_0_9/core/engines.html>`_

* sqlite: ``sqlite:///%(here)s/db.sqlite``
* sqlite (in-memory): ``sqlite://``
* mysql: ``mysql://root@127.0.0.1:3306/pypi?charset=utf8mb4``
* postgres: ``postgresql://postgres@127.0.0.1:5432/postgres``

.. warning::
<commit_msg>remove ref. of in memory sqlite for doc<commit_after>.. _cache:

Caching Backends
================
PyPICloud stores the packages in a storage backend (typically S3), but that backend
is not necessarily efficient for frequently reading metadata. So instead of
hitting S3 every time we need to find a list of package versions, we store all
that metadata in a cache. The cache does not have to be backed up because it is
only a local cache of data that is permanently stored in the storage backend.

SQLAlchemy
----------
Set ``pypi.db = sql`` OR ``pypi.db = pypicloud.cache.SQLCache`` OR leave it out
completely since this is the default.

``db.url``
~~~~~~~~~~
**Argument:** string

The database url to use for the caching database. Should be a `SQLAlchemy url
<http://docs.sqlalchemy.org/en/rel_0_9/core/engines.html>`_

* sqlite: ``sqlite:///%(here)s/db.sqlite``
* mysql: ``mysql://root@127.0.0.1:3306/pypi?charset=utf8mb4``
* postgres: ``postgresql://postgres@127.0.0.1:5432/postgres``

.. warning::

{'fraction_non_alphanumeric': 0.14548162859980138, 'fraction_numerical': 0.025819265143992055, 'mean_word_length': 4.302631578947368, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '1736376', 'n_tokens_mistral': 664, 'n_tokens_neox': 625, 'n_words': 244}