Package com.atlassian.cache
Class CacheSettingsBuilder
java.lang.Object
com.atlassian.cache.CacheSettingsBuilder
A builder for creating
CacheSettings instances.- Since:
- 2.0
-
Constructor Summary
ConstructorsConstructorDescriptionConstructorCacheSettingsBuilder(CacheSettings settings) Constructor that initializes the builder with the settings from aCacheSettingsinstance -
Method Summary
Modifier and TypeMethodDescriptionbuild()expireAfterAccess(long expireAfter, TimeUnit timeUnit) Set a hint for the cache regarding how long entries should be held in the cache.expireAfterWrite(long expireAfter, TimeUnit timeUnit) Set a hint for the cache regarding how long entries should be held in the cache.Indicates that this cache can be flushed by the cache manager when desired.local()Indicates that this cache should be local to the node (JVM) where the cache is created.maxEntries(int maxEntries) Indicates that this cache can have a maximum number of entries.remote()Indicates that this cache should be clustered in a clustered deployment.Indicates that in a clustered environment with replicated caches, this cache should replicate asynchronously.Indicates that in a clustered environment with replicated caches, this cache should replicate synchronously.Indicates that in a clustered environment with replicated caches, this cache should replicate put and update operations by copying the relevant key and value across the wire (requiring both of them to beSerializable).Indicates that in a clustered environment with replicated caches, this cache should replicate by sending only the key across the wire, for invalidation by the other nodes in the cluster; this requires only the key to beSerializable.Indicates that this cache should not record statistics.Indicates that this cache should record statistics.Indicates that this cache cannot be flushed by the cache manager when desired.
-
Constructor Details
-
CacheSettingsBuilder
public CacheSettingsBuilder()Constructor -
CacheSettingsBuilder
Constructor that initializes the builder with the settings from aCacheSettingsinstance- Parameters:
settings- the instance to initialize the builder with
-
-
Method Details
-
build
- Returns:
- a new
CacheSettingsinstance with
-
expireAfterAccess
@Nonnull public CacheSettingsBuilder expireAfterAccess(long expireAfter, @Nonnull TimeUnit timeUnit) Set a hint for the cache regarding how long entries should be held in the cache.- Parameters:
expireAfter- Time to retain entries for since their last access.timeUnit- TheTimeUnitfor the time- Returns:
- this builder
-
expireAfterWrite
Set a hint for the cache regarding how long entries should be held in the cache.- Parameters:
expireAfter- Time to retain entries from when they were created.timeUnit- TheTimeUnitfor the time- Returns:
- this builder
-
flushable
Indicates that this cache can be flushed by the cache manager when desired.- Returns:
- this builder
-
unflushable
Indicates that this cache cannot be flushed by the cache manager when desired.- Returns:
- this builder
-
maxEntries
Indicates that this cache can have a maximum number of entries.- Parameters:
maxEntries- The maximum number of entries. Must be greater than zero.- Returns:
- this builder
-
replicateAsynchronously
Indicates that in a clustered environment with replicated caches, this cache should replicate asynchronously. By default, it is up to the host application as to whether replication is synchronous or asynchronous.
When it is synchronous, cache mutations block on the originating node until all nodes in the cluster have replicated the mutation. Asynchronous replication provides greater responsiveness at the expense of consistency.- Returns:
- this builder
-
replicateSynchronously
Indicates that in a clustered environment with replicated caches, this cache should replicate synchronously.- Returns:
- this builder
- Since:
- 2.3.0
- See Also:
-
replicateViaCopy
Indicates that in a clustered environment with replicated caches, this cache should replicate put and update operations by copying the relevant key and value across the wire (requiring both of them to beSerializable).
By default, it is up to the host application as to whether replication is via copy or invalidation.- Returns:
- this builder
- See Also:
-
replicateViaInvalidation
Indicates that in a clustered environment with replicated caches, this cache should replicate by sending only the key across the wire, for invalidation by the other nodes in the cluster; this requires only the key to beSerializable.
By default, it is up to the host application as to whether replication is via copy or invalidation.- Returns:
- this builder
- Since:
- 2.3.0
- See Also:
-
local
Indicates that this cache should be local to the node (JVM) where the cache is created. By default, caches will be clustered in a clustered deployment.- Returns:
- this builder
-
remote
Indicates that this cache should be clustered in a clustered deployment.- Returns:
- this builder
-
statisticsEnabled
Indicates that this cache should record statistics.- Returns:
- this builder
-
statisticsDisabled
Indicates that this cache should not record statistics.- Returns:
- this builder
-