Skip to content

Cache-Only is a minimal library augmenting the Spring cache abstraction with a way for caching bulk API calls.

License

Notifications You must be signed in to change notification settings

nagyesta/cache-only

Repository files navigation

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

  • Searching for a set of your parcels over an API allowing you to enter up to 10 tracking Ids at a time
  • Loading responses to a few comment threads under your blog post, article, video
  • Comparing 2-5 similar items in a webshop
  • Loading stock updates for a watchlist of stocks in a single request

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.

About

Cache-Only is a minimal library augmenting the Spring cache abstraction with a way for caching bulk API calls.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages