akka/akka-http

Add refreshAfterWrite operation to caching API

Open

#1,537 opened on Nov 21, 2017

View on GitHub
 (1 comment) (0 reactions) (0 assignees)Scala (1,311 stars) (598 forks)batch import
1 - triagedhelp wantedt:caching

Description

Idea via @ben-manes

A feature that you may want to consider adding someday is refreshAfterWrite. This was not provided by Spray, but is useful when using expiration. This way active entries will be asynchronously reloaded so that a periodic delay (expire-compute cycles) is not observed, which reduces user-facing latencies.

Unfortunately this features requires that the AsyncCacheLoader be a real implementation, since the reload logic might differ from a full load (e.g. recheck external timestamps before an expensive computation). Since we want to promote users to memoize through the cache (via a LoadingCache) some features are only available in that form (e.g. bulk gets).

If we need to change API slightly or break bin-compat that's fine still, since the API is marked ApiMayChange (as of writing this at least, November 2017)

Contributor guide