com.atlassian.confluence.cache
Class DefaultCacheSettingsManager

java.lang.Object
  extended by com.atlassian.confluence.cache.DefaultCacheSettingsManager
All Implemented Interfaces:
CacheSettingsManager, org.springframework.beans.factory.InitializingBean

public class DefaultCacheSettingsManager
extends java.lang.Object
implements CacheSettingsManager, org.springframework.beans.factory.InitializingBean

Implementation of CacheSettingsManager that uses a read-only Configuration file that specifies the cache defaults. The configuration file must be in the format to be parsed using the Typesafe Config Library.

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

A config object may contain the following cacheSettingsOverridesProperties:

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} }
 ]
 


Constructor Summary
DefaultCacheSettingsManager(BootstrapManager bootstrapManager, ClusterManager clusterManager, java.lang.String cacheSettingsDefaults, java.lang.String cacheSettingsOverrides)
           
 
Method Summary
 void afterPropertiesSet()
           
 com.atlassian.cache.CacheSettings obtainDefaults(java.lang.String name)
          Obtains cache settings for the specified cache.
 boolean saveSettings()
          Persists all changes made so far by update* methods.
 com.atlassian.fugue.Option<java.lang.Integer> updateMaxEntries(java.lang.String name, int newValue)
          Updates max entries settings for the specified cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultCacheSettingsManager

public DefaultCacheSettingsManager(BootstrapManager bootstrapManager,
                                   ClusterManager clusterManager,
                                   java.lang.String cacheSettingsDefaults,
                                   java.lang.String cacheSettingsOverrides)
                            throws java.io.IOException
Throws:
java.io.IOException
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
java.lang.Exception

updateMaxEntries

public com.atlassian.fugue.Option<java.lang.Integer> updateMaxEntries(java.lang.String name,
                                                                      int newValue)
Description copied from interface: CacheSettingsManager
Updates max entries settings for the specified cache.

Specified by:
updateMaxEntries in interface CacheSettingsManager
Parameters:
name - the name of the cache to update
Returns:
the previous value of the specified max entries if any have

saveSettings

public boolean saveSettings()
Description copied from interface: CacheSettingsManager
Persists all changes made so far by update* methods.

Specified by:
saveSettings in interface CacheSettingsManager
Returns:
true if changes were persisted successfully

obtainDefaults

public com.atlassian.cache.CacheSettings obtainDefaults(java.lang.String name)
Description copied from interface: CacheSettingsManager
Obtains cache settings for the specified cache.

Specified by:
obtainDefaults in interface CacheSettingsManager
Parameters:
name - the name of the cache to obtain settings
Returns:
cache settings


Copyright © 2003-2014 Atlassian. All Rights Reserved.