com.atlassian.cache
Class CacheSettingsBuilder

java.lang.Object
  extended by com.atlassian.cache.CacheSettingsBuilder

@PublicApi
public class CacheSettingsBuilder
extends Object

A builder for creating CacheSettings instances.

Since:
2.0

Constructor Summary
CacheSettingsBuilder()
           
 
Method Summary
 CacheSettings build()
           
 CacheSettingsBuilder expireAfterAccess(long expireAfter, TimeUnit timeUnit)
          Set a hint for the cache regarding how long entries should be held in the cache.
 CacheSettingsBuilder expireAfterWrite(long expireAfter, TimeUnit timeUnit)
          Set a hint for the cache regarding how long entries should be held in the cache.
 CacheSettingsBuilder flushable()
          Indicates that this cache can be flushed by the cache manager when desired.
 CacheSettingsBuilder local()
          Indicates that this cache should be local to the node (JVM) where the cache is created.
 CacheSettingsBuilder maxEntries(int maxEntries)
          Indicates that this cache can have a maximum number of entries.
 CacheSettingsBuilder remote()
          Indicates that this cache should be clustered in a clustered deployment.
 CacheSettingsBuilder replicateAsynchronously()
          Indicates that in a clustered environment with replicated caches, this cache should replicate asynchronously.
 CacheSettingsBuilder 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 be Serializable).
 CacheSettingsBuilder unflushable()
          Indicates that this cache cannot be flushed by the cache manager when desired.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheSettingsBuilder

public CacheSettingsBuilder()
Method Detail

build

public CacheSettings build()
Returns:
a new CacheSettings instance with

expireAfterAccess

public CacheSettingsBuilder expireAfterAccess(long expireAfter,
                                              @NotNull
                                              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 - The TimeUnit for the time
Returns:
this builder

expireAfterWrite

public CacheSettingsBuilder expireAfterWrite(long expireAfter,
                                             @NotNull
                                             TimeUnit timeUnit)
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 - The TimeUnit for the time
Returns:
this builder

flushable

public CacheSettingsBuilder flushable()
Indicates that this cache can be flushed by the cache manager when desired.

Returns:
this builder

unflushable

public CacheSettingsBuilder unflushable()
Indicates that this cache cannot be flushed by the cache manager when desired.

Returns:
this builder

maxEntries

public CacheSettingsBuilder maxEntries(int 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

public CacheSettingsBuilder replicateAsynchronously()
Indicates that in a clustered environment with replicated caches, this cache should replicate asynchronously. By default, replication is synchronous, i.e. 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

replicateViaCopy

public CacheSettingsBuilder 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 be Serializable). By default, put and update operations are replicated by sending only the key across the wire, for invalidation by the other nodes in the cluster; this requires only the key to be Serializable.

Returns:
this builder

local

public CacheSettingsBuilder 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

public CacheSettingsBuilder remote()
Indicates that this cache should be clustered in a clustered deployment.

Returns:
this builder


Copyright © 2014 Atlassian. All Rights Reserved.