Skip to content

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

@mkdir700

Description

@mkdir700

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.

  • Cacheable

Annotation indicating that the result of invoking a method (or all methods in a class) can be cached.

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

  • CachePut

In contrast to the @Cacheable annotation, this annotation does not cause the advised method to be skipped. Rather, it always causes the method to be invoked and its result to be stored in the associated cache if the condition() and unless() expressions match accordingly.

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

  • CacheEvict

Annotation indicating that a method (or all methods on a class) triggers a cache evict operation.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions