public final class BackingStorePolicy extends Object
NamedCache
interacts with a backing store. A BackingStorePolicy is associated with a
NamedCache
and BackingStore
instance through a call to NamedCache.setBackingStoreAdapter()
.
The BackingStorePolicy
controls read-through, write-through, refresh-ahead, and write-behind
behavior when ScaleOut StateServer is being used as cache for a persistent backing store (such as a database). Use the
enableAsyncOperations
property to enable asynchronous refresh-ahead and write-behind operations.
If read-through operations are enabled, it is not desirable for every client process to simultaneously query the database
when a cache miss occurs, so the enableReadThrough
property will affect the behavior of the NamedCache.retrieve
and
NamedCache.get
methods when a cache miss occurs.
The first client to perform a retrieval operation on an object that's missing from the cache will have its BackingStore.load
implementation invoked. While the
backing store is being queried, other clients requesting this object will repeatedly poll until the object has been inserted into the cache. The frequency of the
polling behavior can be controlled by using NamedCache.setReadPendingRetryInterval
and NamedCache.setMaxReadThroughPendingAttempts
methods.
The enableWriteThrough
property is used to indicate to the StateServer that the client will be performing write-through operations via an
implementation of BackingStore.store
.
Changing properties of the BackingStorePolicy
after a call to NamedCache.setBackingStoreAdapter
will not change
the NamedCache
's behavior - setBackingStoreAdapter
must be called again for the new policy options to take
effect.
Constructor and Description |
---|
BackingStorePolicy()
Creates a BackingStorePolicy object with all options set to
false . |
BackingStorePolicy(boolean enableAsyncOperations,
boolean enableReadThrough,
boolean enableWriteThrough)
Creates a BackingStorePolicy object.
|
Modifier and Type | Method and Description |
---|---|
boolean |
getEnableAsyncOperations()
If
true , a client will handle asynchronous refresh-ahead/write-behind operations. |
boolean |
getEnableReadThrough()
If
true , a client will populate the StateServer automatically from a database (or
other type of backing store) when a cache miss occurs by invoking the BackingStore.load
method. |
boolean |
getEnableWriteThrough()
If
true , a client will synchronously write changes to a database (or
other type of backing store) when a cached object is updated or created in the cache
by invoking the BackingStore.store method. |
void |
setEnableAsyncOperations(boolean enableAsyncOperations)
If
true , a client will handle asynchronous refresh-ahead/write-behind operations. |
void |
setEnableReadThrough(boolean enableReadThrough)
If
true , a client will populate the StateServer automatically from a database (or
other type of backing store) when a cache miss occurs by invoking the BackingStore.load
method. |
void |
setEnableWriteThrough(boolean enableWriteThrough)
If
true , a client will synchronously write changes to a database (or
other type of backing store) when a cached object is updated or created in the cache
by invoking the BackingStore.store method. |
public BackingStorePolicy()
false
.public BackingStorePolicy(boolean enableAsyncOperations, boolean enableReadThrough, boolean enableWriteThrough)
enableAsyncOperations
- Indicates whether this client will handle asynchronous refresh-ahead/write-behind operationsenableReadThrough
- If true
, a client will populate the StateServer automatically from a database (or
other type of backing store) when a cache miss occurs by invoking the BackingStore.load
methodenableWriteThrough
- If true
, a client will synchronously write changes to a database (or
other type of backing store) when a cached object is updated or created in the cache
by invoking the BackingStore.store
methodpublic boolean getEnableAsyncOperations()
true
, a client will handle asynchronous refresh-ahead/write-behind operations.enableAsyncOperations
valuepublic void setEnableAsyncOperations(boolean enableAsyncOperations)
true
, a client will handle asynchronous refresh-ahead/write-behind operations.enableAsyncOperations
- new enableAsyncOperations
valuepublic boolean getEnableReadThrough()
true
, a client will populate the StateServer automatically from a database (or
other type of backing store) when a cache miss occurs by invoking the BackingStore.load
method.enableReadThrough
valuepublic void setEnableReadThrough(boolean enableReadThrough)
true
, a client will populate the StateServer automatically from a database (or
other type of backing store) when a cache miss occurs by invoking the BackingStore.load
method.enableReadThrough
- new enableReadThrough
valuepublic boolean getEnableWriteThrough()
true
, a client will synchronously write changes to a database (or
other type of backing store) when a cached object is updated or created in the cache
by invoking the BackingStore.store
method.enableWriteThrough
valuepublic void setEnableWriteThrough(boolean enableWriteThrough)
true
, a client will synchronously write changes to a database (or
other type of backing store) when a cached object is updated or created in the cache
by invoking the BackingStore.store
method.enableWriteThrough
- new enableWriteThrough
valueCopyright (C) 2007-2014 ScaleOut Software, Inc.