<commit_before>fcache
======

About
-----

fcache is a simple, persistent, file-based cache module for Python. It uses `cPickle <http://docs.python.org/2/library/pickle.html#module-cPickle>`_ to store objects into a cache file and `appdirs <http://pypi.python.org/pypi/appdirs>`_ to ensure that cache files are stored in platform-appropriate, application-specific directories. It supports optional, time-based data expiration.

It's Simple
-----------

.. code:: python

    >>> import fcache
    >>> cache = fcache.Cache("population", "statistics-fetcher")
    >>> cache.set("chicago", 9729825)
    >>> print cache.get("chicago")
    9729825

Using fcache is as simple as creating a ``Cache`` object, setting data, and getting data back.

It's Persistent
---------------

.. code:: python

    >>> exit()
    $ python
    >>> import fcache
    >>> cache = fcache.Cache("population", "statistics-fetcher")
    >>> print cache.get("chicago")
    9729825

Cached data doesn't disappear when you stop using a ``Cache`` object. When you create a new object with the same arguments, your data is still there, just like you left it.

It's File-Based
---------------

.. code:: python

    >>> print cache.filename
    /Users/tsr/Library/Caches/statistics-fetcher/248081ecb337c85ec8e4330e6099625a

Cached data is stored in a file, plain and simple. You can see it on the file system. You can delete it, copy it, or write your own library to open it.

It's Time-Aware
---------------

.. code:: python
    >>> import time
    >>> cache.set("chicago", 9729825, 30)
    >>> print cache.get("chicago")
    9729825
    >>> time.sleep(30)
    >>> print cache.get("chicago")<commit_msg>fixed ReST typo<commit_after>fcache
======

About
-----

fcache is a simple, persistent, file-based cache module for Python. It uses `cPickle <http://docs.python.org/2/library/pickle.html#module-cPickle>`_ to store objects into a cache file and `appdirs <http://pypi.python.org/pypi/appdirs>`_ to ensure that cache files are stored in platform-appropriate, application-specific directories. It supports optional, time-based data expiration.

It's Simple
-----------

.. code:: python

    >>> import fcache
    >>> cache = fcache.Cache("population", "statistics-fetcher")
    >>> cache.set("chicago", 9729825)
    >>> print cache.get("chicago")
    9729825

Using fcache is as simple as creating a ``Cache`` object, setting data, and getting data back.

It's Persistent
---------------

.. code:: python

    >>> exit()
    $ python
    >>> import fcache
    >>> cache = fcache.Cache("population", "statistics-fetcher")
    >>> print cache.get("chicago")
    9729825

Cached data doesn't disappear when you stop using a ``Cache`` object. When you create a new object with the same arguments, your data is still there, just like you left it.

It's File-Based
---------------

.. code:: python

    >>> print cache.filename
    /Users/tsr/Library/Caches/statistics-fetcher/248081ecb337c85ec8e4330e6099625a

Cached data is stored in a file, plain and simple. You can see it on the file system. You can delete it, copy it, or write your own library to open it.

It's Time-Aware
---------------

.. code:: python

    >>> import time
    >>> cache.set("chicago", 9729825, 30)
    >>> print cache.get("chicago")
    9729825
    >>> time.sleep(30)
    >>> print cache.get("chicago")
{'fraction_non_alphanumeric': 0.15536301165222588, 'fraction_numerical': 0.03764565282342396, 'mean_word_length': 3.0829268292682928, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 91, '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': '1612988', 'n_tokens_mistral': 1106, 'n_tokens_neox': 990, 'n_words': 345}