Default Cache

The defaultCache element is in itself a structure of configuration data for the default cache provider of type cachebox.system.cache.providers.CacheBoxProvider. This is a reserved cache name and it is MANDATORY to declare and its name or type cannot be changed.

However, if you are using CacheBox within a ColdBox application, the provider will switch itself to cachebox.system.cache.providers.CacheBoxColdBoxProvider by using the coldboxEnabled key. So let's see the configuration keys for our default cache.

Default Cache Properties:

Eviction Policies

  • LFU (Least Frequently Used)

  • LRU (Least Recently Used)

  • FIFO (First In First Out)

  • Custom: You can also build your own and pass the instantiation path in this setting

Object Stores

  • ConcurrentStore - Uses concurrent hashmaps for increased performance

  • ConcurrentSoftReferenceStore - Concurrent hashmaps plus java soft references for JVM memory sensitivity

  • DiskStore - Uses a physical disk location for caching (Uses java serialization for complex objects)

  • JDBCStore - Uses a JDBC datasource for caching (Uses java serialization for complex objects)

  • Custom : You can also build your own and pass the instantiation path in this setting.

Caution : Please note that each object store could have more configuration properties that you will need to add to the configuration structure. To find out about these extra configuration properties, please see the Object Store's section.

Example:

// The CacheBox configuration structure DSL
cacheBox = {
    // Please note that each object store could have more configuration properties
    defaultCache = {
        objectDefaultTimeout = 60,
        objectDefaultLastAccessTimeout = 30,
        useLastAccessTimeouts = true,
        reapFrequency = 2,
        freeMemoryPercentageThreshold = 0,
        evictionPolicy = "LRU",
        evictCount = 1,
        maxObjects = 200,
        // Our default store is the concurrent soft reference
        objectStore = "ConcurrentSoftReferenceStore",
        // This switches the internal provider from normal cacheBox to coldbox enabled cachebox
        coldboxEnabled = false,
        resetTimeoutOnAccess = false
    },
};

Last updated