- All Known Implementing Classes:
AndroidCacheService
,DefaultCacheService
,DesktopCacheService
,DummyCacheService
,IOSCacheService
public interface CacheService
The cache service provides a simple API to weakly cache objects in memory. There is no
guarantee that items being put in the cache will be retained for any minimum amount of time.
They will be garbage collected when necessary.
Example
CacheService.create().ifPresent(service -> {
Cache<String, String> cache = service.getCache("simpleCache");
cache.put("key", "value");
String value = cache.get("key");
});
Android Configuration: none
iOS Configuration: none
- Since:
- 3.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic Optional<CacheService>
create()
Returns an instance ofCacheService
.<K,
V> Cache<K, V> Returns aCache
instance.
-
Method Details
-
create
Returns an instance ofCacheService
.- Returns:
- An instance of
CacheService
.
-
getCache
Returns aCache
instance. The name is used to allow for multiple cache instances to be created, with the name being a unique identifier, returning the same cache every time when given the same name.- Type Parameters:
K
- The key type for the cacheV
- The value type for the cache- Parameters:
cacheName
- The name of the cache.- Returns:
- A named
Cache
instance.
-