comeuplater / Fastapi_cache
Licence: mit
FastAPI simple cache
Stars: ✭ 96
Programming Languages
python
139335 projects - #7 most used programming language
Projects that are alternatives of or similar to Fastapi cache
Java Knowledge Mind Map
【🌱🌱Java服务端知识技能图谱】用思维脑图梳理汇总Java服务端知识技能
Stars: ✭ 787 (+719.79%)
Mutual labels: redis, cache
Weixinmpsdk
微信全平台 SDK Senparc.Weixin for C#,支持 .NET Framework 及 .NET Core、.NET 6.0。已支持微信公众号、小程序、小游戏、企业号、企业微信、开放平台、微信支付、JSSDK、微信周边等全平台。 WeChat SDK for C#.
Stars: ✭ 7,098 (+7293.75%)
Mutual labels: redis, cache
Bloom
🌸 HTTP REST API caching middleware, to be used between load balancers and REST API workers.
Stars: ✭ 553 (+476.04%)
Mutual labels: redis, cache
Easycaching
💥 EasyCaching is an open source caching library that contains basic usages and some advanced usages of caching which can help us to handle caching more easier!
Stars: ✭ 1,047 (+990.63%)
Mutual labels: redis, cache
Gocache
☔️ A complete Go cache library that brings you multiple ways of managing your caches
Stars: ✭ 775 (+707.29%)
Mutual labels: redis, cache
Exchange Rates
💱 Querying a rate-limited currency exchange API using Redis as a cache
Stars: ✭ 37 (-61.46%)
Mutual labels: redis, cache
Lada Cache
A Redis based, fully automated and scalable database cache layer for Laravel
Stars: ✭ 424 (+341.67%)
Mutual labels: redis, cache
Redis Tag Cache
Cache and invalidate records in Redis with tags
Stars: ✭ 48 (-50%)
Mutual labels: redis, cache
Laravel Eloquent Query Cache
Adding cache on your Laravel Eloquent queries' results is now a breeze.
Stars: ✭ 529 (+451.04%)
Mutual labels: redis, cache
Kong Plugin Response Cache
A Kong plugin that will cache responses in redis
Stars: ✭ 66 (-31.25%)
Mutual labels: redis, cache
Aiocache
Asyncio cache manager for redis, memcached and memory
Stars: ✭ 496 (+416.67%)
Mutual labels: redis, cache
Smartsql
SmartSql = MyBatis in C# + .NET Core+ Cache(Memory | Redis) + R/W Splitting + PropertyChangedTrack +Dynamic Repository + InvokeSync + Diagnostics
Stars: ✭ 775 (+707.29%)
Mutual labels: redis, cache
Apicache
Simple API-caching middleware for Express/Node.
Stars: ✭ 957 (+896.88%)
Mutual labels: redis, cache
Ledge
An RFC compliant and ESI capable HTTP cache for Nginx / OpenResty, backed by Redis
Stars: ✭ 412 (+329.17%)
Mutual labels: redis, cache
Object Cache
Simple Ruby object caching solution using Redis as a backend
Stars: ✭ 50 (-47.92%)
Mutual labels: redis, cache
FastAPI Cache
Implements simple lightweight cache system as dependencies in FastAPI.
Installation
pip install fastapi-cache
Usage example
from fastapi import Depends, FastAPI
from fastapi_cache import caches, close_caches
from fastapi_cache.backends.redis import CACHE_KEY, RedisCacheBackend
app = FastAPI()
def redis_cache():
return caches.get(CACHE_KEY)
@app.get('/')
async def hello(
cache: RedisCacheBackend = Depends(redis_cache)
):
in_cache = await cache.get('some_cached_key')
if not in_cache:
await cache.set('some_cached_key', 'new_value', 5)
return {'response': in_cache or 'default'}
@app.on_event('startup')
async def on_startup() -> None:
rc = RedisCacheBackend('redis://redis')
caches.set(CACHE_KEY, rc)
@app.on_event('shutdown')
async def on_shutdown() -> None:
await close_caches()
TODO
- [X] Add tests
- [ ]
Add registry decorator - [ ] Add dependency for requests caching
Acknowledgments
Changelog
-
0.0.6 Added typings for backends. Specific arguments now need to be passed through **kwargs. Set default encoding to utf-8 for redis backend, removed default TTL for redis keys.
-
0.1.0 Added TTL support for InMemoryCacheBackend. Added
expire()
method that update ttl value for key.
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].