Flashback cache
A simple zero-dependencies non-distributed Time to Life in-memory cache.
Motivation
There is a lot of cache solution in market full of capabilities, therefore why another cache system? Basically to have some low-weight short-time cache for medium time consumption operations.
Quick start
(Please read our Javadoc for further information)
- First of all include the Jar file in your compile and execution classpath. Maven
<dependency>
<groupId>org.bytemechanics</groupId>
<artifactId>flashback-cache</artifactId>
<version>X.X.X</version>
</dependency>
Graddle
dependencies {
compile 'org.bytemechanics:flashback-cache:X.X.X'
}
- Allocate the cache service who will store all the cache values, or use the provided singleton
package mypackage;
import org.bytemechanics.cache.flashback.service.CacheServiceSingleton;
public class MyClass{
private static final CacheServiceSingleton cacheService=CacheServiceSingleton.getInstance();
}
- Create a new cache
- Infinite cache
MyObject myResolvedValue=cacheService.from("my.cache.key",() -> methodRecoverCacheValue());
- TTL cache (will be keep the same value until the next recover after 2 minutes)
MyObject myResolvedValue=cacheService.from("my.cache.key",2l,ChronoUnit.MINUTES,() -> methodRecoverCacheValue());