A library that contains scala caching helper code. A fork and new home of the former Gilt Foundation Classes (
com.gilt.gfc), now called the GFC Collective, maintained by some of the original authors.
The latest version is 1.0.0, which is cross-built against Scala 2.12.x and 2.13.x.
If you're using SBT, add the following line to your build file:
libraryDependencies += "org.gfccollective" %% "gfc-cache" % "1.0.0"
For Maven and other build tools, you can visit search.maven.org. (This search will also list other available libraries from the GFC Collective.)
Contents and Example Usage
org.gfccollective.cache.AsyncCache & AsyncCacheImpl
AsyncCache represents an asynchronous cache. It may not contain the whole data, and will return
Future[Option[V]] to show that the value may be lazy-loaded by issuing a remote call.
AsyncCacheImpl is an implementation of
AsyncCache that adds build-load functionality, which requires a load function to be implemented, which is called on cache-miss.
org.gfccollective.cache.SyncCache & SyncCacheImpl
SyncCache represents an in-memory cache, returning values as
Option[V] indicating that no values are lazy-loaded on cache-miss.
SyncCacheImpl is an implementation of
SyncCache that adds build-load functionality, which requires a load function to be implemented, which is called on cache-miss.
Mix in this trait to provide configuration for the cache. The following parameters are needed:
refreshPeriodMs: how often to reload the cache, in millis.
cacheInitStrategy: how to initialize the cache, either synchronously or asynchronously.
Code coverage report
$ sbt clean coverage test coverageReport
Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0