long2ice / fastapi-cache

fastapi-cache is a tool to cache fastapi response and function result, with backends support redis and memcached.
https://github.com/long2ice/fastapi-cache
Apache License 2.0
1.22k stars 152 forks source link

Implement `@cacheable, @cache_put, @cache_evict` like Spring cache. #96

Open mkdir700 opened 1 year ago

mkdir700 commented 1 year ago

This idea comes from Spring Cache, which mainly provides caching function for methods or functions, similar to functools.cache in Python.

These features are often applied to "CRUD" methods, while the target of fastapi-cache is HTTP interface functions. Therefore, I am not sure if these features can be implemented in fastapi-cache.

https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/cache/annotation/Cacheable.html

https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/cache/annotation/CachePut.html

https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/cache/annotation/CacheEvict.html


If you have any further questions, please leave a message and I will reply as soon as possible.

mjpieters commented 1 year ago

What's the status of this issue, and could I request an english version?

mkdir700 commented 1 year ago

What's the status of this issue, and could I request an english version?

I'm very sorry, I have now updated this issue in English.

mjpieters commented 1 year ago

Thanks for updating, the summaries are really helpful!

I can kind-of see this work for FastAPI-Cache too, provided the arguments are compatible. It's something to think about for a post-v1.0.0 version.

mkdir700 commented 1 year ago

Yes, we can consider whether to implement it after version V1.0.0

vithu30 commented 1 year ago

is this feature added in newer release?