Metadata-Version: 2.1
Name: aiohttp-client-cache
Version: 0.1.0
Summary: Persistent cache for aiohttp requests
Home-page: https://github.com/JWCook/aiohttp-client-cache
Author: Jordan Cook
License: BSD License
Keywords: aiohttp,async,asyncio,cache,client,http,persistence,requests
Platform: UNKNOWN
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Description-Content-Type: text/markdown
Requires-Dist: aiohttp
Requires-Dist: attrs
Provides-Extra: backends
Requires-Dist: boto3 ; extra == 'backends'
Requires-Dist: pymongo ; extra == 'backends'
Requires-Dist: redis ; extra == 'backends'
Provides-Extra: build
Requires-Dist: coveralls ; extra == 'build'
Requires-Dist: twine ; extra == 'build'
Requires-Dist: wheel ; extra == 'build'
Provides-Extra: dev
Requires-Dist: coveralls ; extra == 'dev'
Requires-Dist: twine ; extra == 'dev'
Requires-Dist: wheel ; extra == 'dev'
Requires-Dist: boto3 ; extra == 'dev'
Requires-Dist: pymongo ; extra == 'dev'
Requires-Dist: redis ; extra == 'dev'
Requires-Dist: m2r2 ; extra == 'dev'
Requires-Dist: Sphinx (~=3.2.1) ; extra == 'dev'
Requires-Dist: sphinx-autodoc-typehints ; extra == 'dev'
Requires-Dist: sphinx-rtd-theme ; extra == 'dev'
Requires-Dist: sphinxcontrib-apidoc ; extra == 'dev'
Requires-Dist: black (==20.8b1) ; extra == 'dev'
Requires-Dist: flake8 ; extra == 'dev'
Requires-Dist: mypy ; extra == 'dev'
Requires-Dist: pytest (>=5.0) ; extra == 'dev'
Requires-Dist: pytest-cov ; extra == 'dev'
Provides-Extra: docs
Requires-Dist: m2r2 ; extra == 'docs'
Requires-Dist: Sphinx (~=3.2.1) ; extra == 'docs'
Requires-Dist: sphinx-autodoc-typehints ; extra == 'docs'
Requires-Dist: sphinx-rtd-theme ; extra == 'docs'
Requires-Dist: sphinxcontrib-apidoc ; extra == 'docs'
Provides-Extra: test
Requires-Dist: black (==20.8b1) ; extra == 'test'
Requires-Dist: flake8 ; extra == 'test'
Requires-Dist: mypy ; extra == 'test'
Requires-Dist: pytest (>=5.0) ; extra == 'test'
Requires-Dist: pytest-cov ; extra == 'test'

# aiohttp-client-cache
See full documentation at https://aiohttp-client-cache.readthedocs.io

[![Documentation Status](https://img.shields.io/readthedocs/aiohttp-client-cache/stable?label=docs)](https://aiohttp-client-cache.readthedocs.io/en/latest/)

<!--- [![Build status](https://github.com/JWCook/aiohttp-client-cache/workflows/Build/badge.svg)](https://github.com/JWCook/aiohttp-client-cache/actions) --->
<!--- [![Coverage Status](https://coveralls.io/repos/github/JWCook/aiohttp-client-cache/badge.svg?branch=master)](https://coveralls.io/github/JWCook/aiohttp-client-cache?branch=master) --->
<!--- [![PyPI](https://img.shields.io/pypi/v/aiohttp-client-cache?color=blue)](https://pypi.org/project/aiohttp-client-cache) --->
<!--- [![PyPI - Python Versions](https://img.shields.io/pypi/pyversions/aiohttp-client-cache)](https://pypi.org/project/aiohttp-client-cache) --->
<!--- [![PyPI - Format](https://img.shields.io/pypi/format/aiohttp-client-cache?color=blue)](https://pypi.org/project/aiohttp-client-cache) --->

`aiohttp-client-cache` is an async persistent cache for [aiohttp](https://docs.aiohttp.org) 
requests, based on [requests-cache](https://github.com/reclosedev/requests-cache).

Not to be confused with [aiohttp-cache](https://github.com/cr0hn/aiohttp-cache), which is a cache
for the aiohttp web server. This package is, as you might guess, specifically for the aiohttp client.

**This is an early work in progress and not yet fully functional!**

## Installation
Requires python 3.7+

Install the latest stable version with pip:
```python
pip install aiohttp-client-cache
```

To set up for local development:

```bash
$ git clone https://github.com/JWCook/aiohttp-client-cache
$ cd aiohttp-client-cache
$ pip install -Ue ".[dev]"
```

## Usage example
```python
from aiohttp_client_cache import CachedSession
session = CachedSession('demo_cache', backend='sqlite')
response = await session.get('http://httpbin.org/get')
```

Afterward, all responses with headers and cookies will be transparently cached to
a database named `demo_cache.sqlite`. For example, following code will take only
1-2 seconds instead of 10, and will run instantly on next launch:

```python
for i in range(10):
    await session.get('http://httpbin.org/delay/1')
```

## Cache Backends
Several backends are available:

* `sqlite`: SQLite database (**default**)
* `redis`: Stores all data in a redis cache (requires [redis-py](https://github.com/andymccurdy/redis-py))
* `mongodb`: MongoDB database (requires [pymongo](https://pymongo.readthedocs.io/en/stable/)))
    * `gridfs`: MongoDB GridFS enables storage of documents greater than 16MB
* `memory`: Not persistent, simply stores all data in Python ``dict`` in memory

You can also provide your own backend by subclassing `aiohttp_client_cache.backends.BaseCache`.

## Expiration
If you are using the `expire_after` parameter , responses are removed from the storage the next time
the same request is made. If you want to manually purge all expired items, you can use
`CachedSession.delete_expired_responses`. Example:

```python
session = CachedSession(expire_after=1)
await session.remove_expired_responses()
```

# History

## 0.1.0
* Initial PyPI release
* First pass at a general refactor and conversion from `requests` to `aiohttp`

## requests-cache
See [requests-cache development history](https://github.com/reclosedev/requests-cache/blob/master/HISTORY.rst)
and [contributors](https://github.com/reclosedev/requests-cache/blob/master/CONTRIBUTORS.rst)
for details on prior changes.


