@FunctionalInterface public interface StorageEntityCacheEvaluator
Note that any implementation of this type must be safe enough to never throw an exception as this would doom the storage thread that executes it. Catching any exception would not prevent the problem for the channel thread as the function has to work in order for the channel to work properly. It is therefore strongly suggested that implementations only use "exception free" logic (like simple arithmetic) or handle any possible exception internally.
| Modifier and Type | Interface and Description |
|---|---|
static class |
StorageEntityCacheEvaluator.Default |
static interface |
StorageEntityCacheEvaluator.Defaults |
static interface |
StorageEntityCacheEvaluator.Validation |
| Modifier and Type | Method and Description |
|---|---|
boolean |
clearEntityCache(long totalCacheSize,
long evaluationTime,
StorageEntity entity) |
default boolean |
initiallyCacheEntity(long totalCacheSize,
long evaluationTime,
StorageEntity entity) |
static StorageEntityCacheEvaluator |
New()
Pseudo-constructor method to create a new
StorageEntityCacheEvaluator instance
using default values defined by StorageEntityCacheEvaluator.Defaults. |
static StorageEntityCacheEvaluator |
New(long timeoutMs)
Pseudo-constructor method to create a new
StorageEntityCacheEvaluator instance
using the passed value and default values defined by StorageEntityCacheEvaluator.Defaults. |
static StorageEntityCacheEvaluator |
New(long timeoutMs,
long threshold)
Pseudo-constructor method to create a new
StorageEntityCacheEvaluator instance
using the passed values. |
boolean clearEntityCache(long totalCacheSize,
long evaluationTime,
StorageEntity entity)
default boolean initiallyCacheEntity(long totalCacheSize,
long evaluationTime,
StorageEntity entity)
static StorageEntityCacheEvaluator New()
StorageEntityCacheEvaluator instance
using default values defined by StorageEntityCacheEvaluator.Defaults.
For explanations and customizing values, see New(long, long).
StorageEntityCacheEvaluator instance.New(long),
New(long, long),
StorageEntityCacheEvaluator.Defaultsstatic StorageEntityCacheEvaluator New(long timeoutMs)
StorageEntityCacheEvaluator instance
using the passed value and default values defined by StorageEntityCacheEvaluator.Defaults.
For explanations and customizing values, see New(long, long).
timeoutMs - the time (in milliseconds, greater than 0) of not being read (the "age"), after which a particular
entity's data will be cleared from the Storage's internal cache.StorageEntityCacheEvaluator instance.one.microstream.exceptions.NumberRangeException - if the passed value is equal to or lower than 0.New(),
New(long, long),
StorageEntityCacheEvaluator.Defaultsstatic StorageEntityCacheEvaluator New(long timeoutMs, long threshold)
StorageEntityCacheEvaluator instance
using the passed values.
In the default implementation, two values are combined to calculate an entity's "cache weight":
its "age" (the time in milliseconds of not being read) and its size in bytes. The resulting value is
in turn compared to an abstract "free space" value, calculated by subtracting the current total cache size
in bytes from the abstract threshold value defined here. If this comparison deems the tested entity
to be "too heavy" for the cache, its data is cleared from the cache. It is also cleared from the cache if its
"age" is greater than the timeout defined here.
This is a relatively simple and extremely fast algorithm to create the following behavior:
timeoutMs - the time (in milliseconds, greater than 0) of not being read (the "age"), after which a particular
entity's data will be cleared from the Storage's internal cache.threshold - an abstract value (greater than 0) to evaluate the product of size and age of an entity in relation
to the current cache size in order to determine if the entity's data shall be cleared from the cache.StorageEntityCacheEvaluator instance.one.microstream.exceptions.NumberRangeException - if any of the passed values is equal to or lower than 0.New(),
New(long),
StorageEntityCacheEvaluator.DefaultsCopyright © 2022 MicroStream Software. All rights reserved.