Class HoconCacheSettingsReader

  • All Implemented Interfaces:
    com.atlassian.cache.CacheSettingsDefaultsProvider

    public final class HoconCacheSettingsReader
    extends Object
    implements com.atlassian.cache.CacheSettingsDefaultsProvider
    Implementation of CacheSettingsDefaultsProvider that uses a read-only Configuration file that specifies the cache defaults. The configuration file must be in HOCON (Human-Optimized Config Object Notation) format.

    The format of the file must include an entry caches which is an array of objects, that each object contains the following cacheSettingsOverridesProperties:

    • name - name of the caches to match. Note that trailing wildcards are supported. E.g. "com.*" will match "com.food" and "com."
    • config - object containing the cacheSettingsOverridesProperties for the cache. See below.

    A config object may contain the following:

    • expire-after-access-secs - used to set the CacheSettingsBuilder.expireAfterAccess(long, TimeUnit) hint
    • expire-after-write-secs - used to set the CacheSettingsBuilder.expireAfterWrite(long, TimeUnit) hint
    • flushable - used to set the CacheSettingsBuilder.flushable() hint
    • local - used to set the CacheSettingsBuilder.local() hint
    • max-entries - used to set the CacheSettingsBuilder.maxEntries(int) hint
    • replicate-async - used to set the CacheSettingsBuilder.replicateAsynchronously() hint
    • replicate-via-copy - used to set CacheSettingsBuilder.replicateViaCopy() hint

    An example minimal configuration file is:

     // Defaults for local caches
     local-defaults = {
         local = true
         flushable = true
         max-entries = 1000
         expire-after-access-secs = 360
     }
    
     // Defaults for replicated caches
     remote-defaults = ${local-defaults} {
         local = false
         replicate-via-copy = true
     }
    
     remote-big = ${remote-defaults} {
         expire-after-write-secs = 42
         flushable = false
         replicate-async = true
         replicate-via-copy = false
         max-entries = 666666
     }
    
     caches = [
         { name = "a.local.cache", config = ${local-defaults} }
         { name = "a.remote.cache", config = ${remote-defaults} }
         { name = "big.ones.*", config = ${remote-big} }
         { name = "reg.+exp[chars(\\", config = ${remote-big} }
         { name = "*", config = ${remote-defaults} }
     ]
     
    Since:
    7.5
    • Constructor Detail

      • HoconCacheSettingsReader

        public HoconCacheSettingsReader​(com.atlassian.dc.filestore.api.FileStore.Path configOverridesPath,
                                        org.springframework.core.io.Resource defaultConfigResource)
    • Method Detail

      • getDefaults

        public com.atlassian.cache.CacheSettings getDefaults​(@NonNull String name)
        Specified by:
        getDefaults in interface com.atlassian.cache.CacheSettingsDefaultsProvider