nagyesta / cache-only

Cache-Only is a minimal library augmenting the Spring cache abstraction with a way for caching bulk API calls.
MIT License
0 stars 0 forks source link

Cache-Only

GitHub license Java version latest-release Maven Central JavaCI

codecov code-climate-maintainability last_commit wiki

About Cache-Only

Cache-Only is a minimal library augmenting the Spring cache abstraction to better support bulk requests.

What does this mean?

Bulk requests are challenging to cache on almost every level due to the fact that they contain multiple things in a collection instead of caching each individual part. Although this is not always an issue, if the users/consumers of our API want to access a slightly different set of items in each request, we cannot meaningfully reduce the number of calls made to the full service by caching the response since the keys we would generate for the items are not likely to fully match next time.

A few examples for these APIs

How will we solve this?

Cache-Only provides a few interfaces:

All of these are glued together by the implementations of CachingServiceTemplate which are managing how the bulk request is split, then each part is looked up from the cache using the cache support. For those which were missed, we can decide to merge into a bulk request and call the real API. When the response is received, we just need to make sure each partial response is saved to the cache one-by-one. (Please check out the wiki for more details)

Additional features

Thanks to the ability of splitting and merging requests and responses, Cache-Only can manage batch size limits and automatic partitioning of the request to let you only focus on what is important and forget about the tedious task of counting items and splitting them into multiple parts when needed.

Examples

The wiki contains a few examples you can use to find out how you can get the most out of this library.