Cache
Talares does not use a caching library of it's own. In stead it leaves supplying a cache implementation up to the user. This is done by creating an instance of one of the caches residing in org.talares.cache for Java and org.talares.api.cache for Scala. Talares will leverage this instance to apply the chosen caching strategy.
Specific caching strategies can be chosen by supplying an instance of the corresponding class. The different strategies are described below.
No cache
When no cache instance or an instance of NoCache is provided, the 'no cache' strategy is chosen. As the name implies this strategy will not cache results retrieved from the webservice.
Simple cache
The 'simple cache' strategy uses the supplied cache implementation to store results retrieved from the webservice. It does not supply any additional logic of it's own. Therefore the configuration of the supplied cache instance, like time to live, is honored.
Auto update cache
When the 'auto update cache' strategy is activated, cached values will be updated using an asynchronous process. This allows for clients to always be served a value from cache while also ensuring that these values are up to date.
A few configuration steps are needed to make this work. First of all the configuration of the cache implementation supplied by the user will have to be modified to accommodate the auto update cache behaviour. For instance a short TTL might cause cached values to be evicted before the library has a chance to update them.
Furthermore, users will have to decide the frequency with which to update the cached values. This can be done in the application.conf file using the key talares.cache.refreshratio. The value specified there represents the number of times a cached item should be allowed to be accessed before an update task is triggered. It is advised to increase this value to an adequate number for high traffic environments. The result of an incrementation of this value might be that some clients receive slightly outdated content, but the load that is relieved from the webservice will be significant.