Class DefaultCache
java.lang.Object
io.fluxzero.sdk.persisting.caching.DefaultCache
- All Implemented Interfaces:
AutoCloseable
Default aggregate cache facade that selects the current SDK cache implementation from Fluxzero cache properties.
Existing applications without a defaults version or explicit MODE_PROPERTY keep the legacy
SoftReferenceCache. Newer applications that use Fluxzero defaults >= 2026.05.25, or set
fluxzero.cache.mode = adaptive, use AdaptiveObjectCache.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final LocalDateFluxzero defaults version from whichDefaultCacheusesAdaptiveObjectCacheby default.static final StringProperty that configures the maximum entry count forAdaptiveObjectCachewhen selected byDefaultCache.static final StringMODE_PROPERTYvalue that selectsAdaptiveObjectCache.static final StringProperty that selects the cache implementation used byDefaultCache.static final StringMODE_PROPERTYvalue that selectsSoftReferenceCache. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a cache using the active Fluxzero property source, or the default property source when no Fluxzero instance is active.DefaultCache(int maxSize) Constructs a cache with a specified max size for the selected implementation.DefaultCache(int maxSize, Duration expiry) Constructs a cache with specified size and expiration for the selected implementation.DefaultCache(io.fluxzero.common.application.PropertySource propertySource) Constructs a cache using the given property source for cache mode and defaults-version selection.DefaultCache(io.fluxzero.common.application.PropertySource propertySource, int maxSize) Constructs a cache using the given property source for cache mode and defaults-version selection, with a custom max size for the selected implementation. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()voidclose()<T> Tcompute(Object id, BiFunction<? super Object, ? super T, ? extends T> mappingFunction) <T> TcomputeIfAbsent(Object id, Function<? super Object, T> mappingFunction) <T> TcomputeIfPresent(Object id, BiFunction<? super Object, ? super T, ? extends T> mappingFunction) booleancontainsKey(Object id) io.fluxzero.common.caching.Cachedelegate()Returns the selected cache implementation.<T> Tdefault <T> TgetOrDefault(Object arg0, T arg1) default booleanisEmpty()<T> voidmodifyEach(BiFunction<? super Object, ? super T, ? extends T> modifierFunction) putIfAbsent(Object id, Object value) io.fluxzero.common.caching.Cacherebuild()io.fluxzero.common.RegistrationregisterEvictionListener(Consumer<io.fluxzero.common.caching.CacheEviction> listener) <T> Tintsize()
-
Field Details
-
ADAPTIVE_DEFAULTS_VERSION
Fluxzero defaults version from whichDefaultCacheusesAdaptiveObjectCacheby default. -
MODE_PROPERTY
Property that selects the cache implementation used byDefaultCache.- See Also:
-
MODE_SOFT_REFERENCE
MODE_PROPERTYvalue that selectsSoftReferenceCache.- See Also:
-
MODE_ADAPTIVE
MODE_PROPERTYvalue that selectsAdaptiveObjectCache.- See Also:
-
MAX_SIZE_PROPERTY
Property that configures the maximum entry count forAdaptiveObjectCachewhen selected byDefaultCache.- See Also:
-
-
Constructor Details
-
DefaultCache
public DefaultCache()Constructs a cache using the active Fluxzero property source, or the default property source when no Fluxzero instance is active. -
DefaultCache
public DefaultCache(io.fluxzero.common.application.PropertySource propertySource) Constructs a cache using the given property source for cache mode and defaults-version selection. -
DefaultCache
public DefaultCache(io.fluxzero.common.application.PropertySource propertySource, int maxSize) Constructs a cache using the given property source for cache mode and defaults-version selection, with a custom max size for the selected implementation. -
DefaultCache
public DefaultCache(int maxSize) Constructs a cache with a specified max size for the selected implementation. -
DefaultCache
Constructs a cache with specified size and expiration for the selected implementation.
-
-
Method Details
-
delegate
public io.fluxzero.common.caching.Cache delegate()Returns the selected cache implementation. -
put
-
putIfAbsent
-
computeIfAbsent
-
computeIfPresent
public <T> T computeIfPresent(Object id, BiFunction<? super Object, ? super T, ? extends T> mappingFunction) -
compute
-
modifyEach
-
get
-
containsKey
-
remove
-
clear
public void clear() -
size
public int size() -
registerEvictionListener
public io.fluxzero.common.Registration registerEvictionListener(Consumer<io.fluxzero.common.caching.CacheEviction> listener) -
rebuild
public io.fluxzero.common.caching.Cache rebuild() -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
getOrDefault
-
isEmpty
default boolean isEmpty()
-