Package org.openspaces.core.space.cache
Class LocalCacheSpaceFactoryBean
java.lang.Object
org.openspaces.core.space.cache.AbstractLocalCacheSpaceFactoryBean
org.openspaces.core.space.cache.LocalCacheSpaceFactoryBean
- All Implemented Interfaces:
ServiceDetailsProvider,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.FactoryBean,org.springframework.beans.factory.InitializingBean
In some cases, the memory capacity of an individual application is not capable of holding all the
information in the local application memory. When this happens, the desired solution will be to
hold only a portion of the information in the application's memory and the rest in a separate
process(s). This mode is also known as two-level cache. In this mode, the cache is divided into
two components, local cache and master cache. The local cache always resides in the physical
address space of the application and the master cache runs in a different process. The master
cache is used to share data among the different embedded local caches running within other
application instances.
In this mode, when a read/get operation is called, a matching object is first looked up in the local embedded cache. If the object is not found in the local cache, it will be searched for in the master cache. If it is not found in the master cache, it will reload the data from the data source. Updates on the central cache will be propagated into all local embedded cache instances in either pull or push mode, using unicast or multicast protocol.
- Author:
- kimchy
-
Field Summary
FieldsFields inherited from interface org.springframework.beans.factory.FactoryBean
OBJECT_TYPE_ATTRIBUTE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddProperty(String name, String value) voidConstructs a new local cacheIJSpacebased on the master local cache set usingsetSpace(IJSpace)and a set of properties driving the actual local cache type from the configuration.voiddestroy()Closes the local cache spaceprotected StringReturns anIJSpacethat is the local cache wrapping the master proxy set usingsetSpace(com.j_spaces.core.IJSpace).Returns the type of the factory object.Retruns one or more service details that the service exposes.voidsetBatchSize(int batchSize) voidsetBatchTimeout(long batchTimeout) voidsetBeanName(String beanName) Spring callback that sets the bean name.voidsetMaxDisconnectionDuration(long maxDisconnectionDuration) voidsetMaxTimeToLive(long maxTimeToLive) voidsetProperties(Properties properties) Sets additional properties for the local cache.voidsetSize(int size) Sets the local cache size.voidSets the master space that a local cache will be built on top.voidsetUpdateMode(int localCacheUpdateMode) If set toSpaceURL.UPDATE_MODE_PULL(1) each update triggers an invalidation event at every cache instance.voidsetUpdateMode(LocalCacheSpaceConfigurer.UpdateMode localCacheUpdateMode) voidsetUpdateModeName(String localCacheUpdateModeName) Allows to set the local cache update mode using a descriptive name instead of integer constants usinglocalCacheUpdateMode.Methods inherited from class org.openspaces.core.space.cache.AbstractLocalCacheSpaceFactoryBean
isSingleton
-
Field Details
-
LOCAL_CACHE_UPDATE_MODE_PUSH
- See Also:
-
LOCAL_CACHE_UPDATE_MODE_PULL
- See Also:
-
-
Constructor Details
-
LocalCacheSpaceFactoryBean
public LocalCacheSpaceFactoryBean()
-
-
Method Details
-
getObject
Returns anIJSpacethat is the local cache wrapping the master proxy set usingsetSpace(com.j_spaces.core.IJSpace). -
getObjectType
Returns the type of the factory object. -
afterPropertiesSet
public void afterPropertiesSet()Constructs a new local cacheIJSpacebased on the master local cache set usingsetSpace(IJSpace)and a set of properties driving the actual local cache type from the configuration. Additional properties are applied based onsetProperties(java.util.Properties). -
destroy
public void destroy()Closes the local cache space -
getServicesDetails
Description copied from interface:ServiceDetailsProviderRetruns one or more service details that the service exposes. -
setBeanName
Spring callback that sets the bean name. -
getBeanName
-
setSpace
Sets the master space that a local cache will be built on top. -
setProperties
Sets additional properties for the local cache. -
addProperty
-
setBatchSize
public void setBatchSize(int batchSize) -
setBatchTimeout
public void setBatchTimeout(long batchTimeout) -
setMaxDisconnectionDuration
public void setMaxDisconnectionDuration(long maxDisconnectionDuration) -
setUpdateMode
public void setUpdateMode(int localCacheUpdateMode) If set toSpaceURL.UPDATE_MODE_PULL(1) each update triggers an invalidation event at every cache instance. The invalidate event marks the object in the local cache instances as invalid. Therefore, an attempt to read this object triggers a reload process in the master space. This configuration is useful in cases where objects are updated frequently, but the updated value is required by the application less frequently.If set to
SpaceURL.UPDATE_MODE_PUSH(2) the master pushes the updates to the local cache, which holds a reference to the same updated object.- See Also:
-
setUpdateMode
-
setUpdateModeName
Allows to set the local cache update mode using a descriptive name instead of integer constants usinglocalCacheUpdateMode. Accepts eitherpushorpull.- See Also:
-
setMaxTimeToLive
public void setMaxTimeToLive(long maxTimeToLive) -
setSize
public void setSize(int size) Sets the local cache size.
-