Metadata-Version: 2.1
Name: temporal-cache
Version: 0.1.4
Summary: Time based function caching
Home-page: https://github.com/timkpaine/temporal-cache
Author: Tim Paine
Author-email: timothy.k.paine@gmail.com
License: Apache 2.0
Keywords: analytics tools
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Description-Content-Type: text/markdown
Requires-Dist: frozendict (>=1.2)
Requires-Dist: tzlocal (>=2.0.0)
Provides-Extra: dev
Requires-Dist: black (>=20.) ; extra == 'dev'
Requires-Dist: bump2version (>=1.0.0) ; extra == 'dev'
Requires-Dist: flake8 (>=3.7.8) ; extra == 'dev'
Requires-Dist: flake8-black (>=0.2.1) ; extra == 'dev'
Requires-Dist: mock ; extra == 'dev'
Requires-Dist: pytest (>=4.3.0) ; extra == 'dev'
Requires-Dist: pytest-cov (>=2.6.1) ; extra == 'dev'
Requires-Dist: Sphinx (>=1.8.4) ; extra == 'dev'
Requires-Dist: sphinx-markdown-builder (>=0.5.2) ; extra == 'dev'
Requires-Dist: frozendict (>=1.2) ; extra == 'dev'
Requires-Dist: tzlocal (>=2.0.0) ; extra == 'dev'

# temporal-cache

Time-based cache invalidation

[![Build Status](https://github.com/timkpaine/temporal-cache/workflows/Build%20Status/badge.svg?branch=main)](https://github.com/timkpaine/temporal-cache/actions?query=workflow%3A%22Build+Status%22)
[![Coverage](https://codecov.io/gh/timkpaine/temporal-cache/branch/main/graph/badge.svg?token=ag2j2TV2wE)](https://codecov.io/gh/timkpaine/temporal-cache)
[![License](https://img.shields.io/github/license/timkpaine/temporal-cache.svg)](https://pypi.python.org/pypi/temporal-cache/)
[![PyPI](https://img.shields.io/pypi/v/temporal-cache.svg)](https://pypi.python.org/pypi/temporal-cache/)
[![Docs](https://img.shields.io/readthedocs/temporal-cache.svg)](https://temporal-cache.readthedocs.io)


## Install

From pip

`pip install temporal-cache`

Or from source

`python setup.py install`

## Why?

I needed something that would automagically refresh at 4:00pm when markets close.

```python3

    @expire(hour=16)
    def fetchFinancialData():

```

## Interval Cache

The interval cache expires every `time` interval since its first use

```python3

    @interval(seconds=5, minutes=2)
    def myfoo():
        '''myfoo's lru_cache will expire 2 minutes, 5 seconds after last use'''
```


## Expire Cache

The expire cache expires on the time given, in scheduler/cron style.

```python3

    @expire(second=5, minute=2)
    def myfoo():
        '''myfoo's lru_cache will expire on the second minute, fifth second of every hour, every day, etc'''
```


## Caveats

Python hashing symantics persist. Dicts will be frozen, lists will be converted to tuples. Users are advised to pre-freeze to avoid issues.


