#
Cache
By default, the core
library has a built-in cache that is enabled. Any expression that is encountered during validation
or canonicalization is being cached. If the cache is full then older entries will be removed.
You can configure the cache through three ways:
#
Property File
Create a ucumate.properties
file in src/main/resources
, i.e.
# Inside a file called ucumate.properties
ucumate.cache.enable=true
ucumate.cache.maxCanonSize=10000
ucumate.cache.maxValSize=10000
ucumate.cache.recordStats=false
ucumate.cache.preheat=true
ucumate.cache.preheat.override=false
#
Properties in Java Code
Create a Properties
object and call initCache
.
Properties props = new Properties();
props.put("ucumate.cache.enable", true);
props.put("ucumate.cache.maxCanonSize", 10000);
props.put("ucumate.cache.maxValSize", 10000);
props.put("ucumate.cache.recordStats", false);
props.put("ucumate.cache.preheat", true);
props.put("ucumate.cache.preheat.override", false);
PersistenceRegistry.initCache(props);
#
Builder Class
There is a fluent builder class to construct cache settings.
Properties props = CacheConfig.builder()
.enable()
.size(10000, 10000)
.recordStats(false)
.preHeat(true)
.build();
PersistenceRegistry.initCache(props);
If you want save the cache between restarts you can add the ucumate-persistence
module that ships with a sqlite database
by default. When the app starts everything from the data storage will be loaded into the cache.
Below are the properties to control the cache behaviour.