All Projects → JWCook → aiohttp-client-cache

JWCook / aiohttp-client-cache

Licence: MIT, BSD-2-Clause licenses found Licenses found MIT LICENSE BSD-2-Clause LICENSE_requests_cache.md
An async persistent cache for aiohttp requests

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to aiohttp-client-cache

rigor
HTTP-based DSL for for validating RESTful APIs
Stars: ✭ 65 (+3.17%)
Mutual labels:  aiohttp, requests
torequests
Async wrapper for requests / aiohttp, and some crawler toolkits. Let synchronization code enjoy the performance of asynchronous programming.
Stars: ✭ 22 (-65.08%)
Mutual labels:  aiohttp, requests
Python Simple Rest Client
Simple REST client for python 3.6+
Stars: ✭ 143 (+126.98%)
Mutual labels:  aiohttp, requests
python3-concurrency
Python3爬虫系列的理论验证,首先研究I/O模型,分别用Python实现了blocking I/O、nonblocking I/O、I/O multiplexing各模型下的TCP服务端和客户端。然后,研究同步I/O操作(依序下载、多进程并发、多线程并发)和异步I/O(asyncio)之间的效率差别
Stars: ✭ 49 (-22.22%)
Mutual labels:  aiohttp, requests
Python3 Concurrency Pics 02
爬取 www.mzitu.com 全站图片,截至目前共5162个图集,16.5万多张美女图片,使用 asyncio 和 aiohttp 实现的异步版本只需要不到2小时就能爬取完成。按日期创建图集目录,保存更合理。控制台只显示下载的进度条,详细信息保存在日志文件中。支持异常处理,不会终止爬虫程序。失败的请求,下次再执行爬虫程序时会自动下载
Stars: ✭ 275 (+336.51%)
Mutual labels:  aiohttp, requests
Uplink
A Declarative HTTP Client for Python
Stars: ✭ 824 (+1207.94%)
Mutual labels:  aiohttp, requests
Pyrez
(ON REWRITE) An easy to use (a)sync wrapper for Hi-Rez Studios API (Paladins, Realm Royale, and Smite), written in Python. 🐍
Stars: ✭ 23 (-63.49%)
Mutual labels:  aiohttp, requests
datanucleus-core
DataNucleus core persistence support - the basis for anything in DataNucleus
Stars: ✭ 112 (+77.78%)
Mutual labels:  persistence
python web scraping
Web scraping using python, requests and selenium
Stars: ✭ 40 (-36.51%)
Mutual labels:  requests
Jawbreaker
A Python obfuscator using HTTP Requests and Hastebin.
Stars: ✭ 50 (-20.63%)
Mutual labels:  requests
dynamodb-onetable
DynamoDB access and management for one table designs with NodeJS
Stars: ✭ 508 (+706.35%)
Mutual labels:  dynamodb
derivejs
DeriveJS is a reactive ODM - Object Document Mapper - framework, a "wrapper" around a database, that removes all the hassle of data-persistence by handling it transparently in the background, in a DRY manner.
Stars: ✭ 54 (-14.29%)
Mutual labels:  persistence
aiohttp-sentry
An aiohttp server middleware for reporting failed requests to Sentry
Stars: ✭ 35 (-44.44%)
Mutual labels:  aiohttp
acord
An API wrapper for discord, built using aiohttp and pydantic.
Stars: ✭ 25 (-60.32%)
Mutual labels:  aiohttp
aws-certified-developer-associate-udemy-notes
AWS Certified Developer Associate Udemy Notes
Stars: ✭ 20 (-68.25%)
Mutual labels:  dynamodb
data
[deprecated] Generate a DynamoDB data access layer from an .arc file. Automatically disambiguates testing (in memory) from deployment staging and production tables
Stars: ✭ 20 (-68.25%)
Mutual labels:  dynamodb
crypto-watcher
Real-time cryptocurrencies prices.
Stars: ✭ 25 (-60.32%)
Mutual labels:  requests
lockbot
🔒 Coordinate use of your team's shared resources, in Slack 🤝
Stars: ✭ 47 (-25.4%)
Mutual labels:  dynamodb
funny-bot
telegram bot fetch photo from gamersky
Stars: ✭ 17 (-73.02%)
Mutual labels:  aiohttp
laravel-dynamodb-session-driver
DynamoDB Session Driver for Laravel 5
Stars: ✭ 15 (-76.19%)
Mutual labels:  dynamodb

aiohttp-client-cache

Build status Documentation Status Codecov PyPI Conda PyPI - Python Versions PyPI - Format

aiohttp-client-cache is an async persistent cache for aiohttp client requests, based on requests-cache.

Features

  • Ease of use: Use as a drop-in replacement for aiohttp.ClientSession
  • Customization: Works out of the box with little to no config, but with plenty of options available for customizing cache expiration and other behavior
  • Persistence: Includes several storage backends: SQLite, DynamoDB, MongoDB, and Redis.

Development Status

This library is a work in progress!

Breaking changes should be expected until a 1.0 release, so version pinning is recommended.

My goal for this library is to eventually have a similar (but not identical) feature set as requests-cache, and also contribute new features from this library back to requests-cache. If there is a feature you want, if you've discovered a bug, or if you have other general feedback, please create an issue for it!

Quickstart

First, install with pip (python 3.7+ required):

pip install aiohttp-client-cache

Basic Usage

Next, use aiohttp_client_cache.CachedSession in place of aiohttp.ClientSession. To briefly demonstrate how to use it:

Replace this:

from aiohttp import ClientSession

async with ClientSession() as session:
    await session.get('http://httpbin.org/delay/1')

With this:

from aiohttp_client_cache import CachedSession, SQLiteBackend

async with CachedSession(cache=SQLiteBackend('demo_cache')) as session:
    await session.get('http://httpbin.org/delay/1')

The URL in this example adds a delay of 1 second, simulating a slow or rate-limited website. With caching, the response will be fetched once, saved to demo_cache.sqlite, and subsequent requests will return the cached response near-instantly.

Configuration

Several options are available to customize caching behavior. This example demonstrates a few of them:

# fmt: off
from aiohttp_client_cache import SQLiteBackend

cache = SQLiteBackend(
    cache_name='~/.cache/aiohttp-requests.db',  # For SQLite, this will be used as the filename
    expire_after=60*60,                         # By default, cached responses expire in an hour
    urls_expire_after={'*.fillmurray.com': -1}, # Requests for any subdomain on this site will never expire
    allowed_codes=(200, 418),                   # Cache responses with these status codes
    allowed_methods=['GET', 'POST'],            # Cache requests with these HTTP methods
    include_headers=True,                       # Cache requests with different headers separately
    ignored_params=['auth_token'],              # Keep using the cached response even if this param changes
    timeout=2.5,                                # Connection timeout for SQLite backend
)

More Info

To learn more, see:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].