com.alachisoft.jvcache.web.caching
Class CacheSyncDependency

java.lang.Object
  extended by com.alachisoft.jvcache.web.caching.CacheSyncDependency

public class CacheSyncDependency
extends java.lang.Object

A client application can have more than one cache instances initialized. CacheSyncDependency keeps the items present in one cache synchronized with the items present in another cache. You can add items with CacheSyncDependency to your application's cache with the Cache.add and Cache.insert methods.

When you add an item to an application's Cache object with CacheSyncDependency, it monitors the remote cache (the cache you want your local cache to be synchronized with) for changes. As soon as an item is updated in or removed from the remote cache this change is automatically updated in the local cache if the CacheSyncDependency was provided with the cache items. This helps you keep your local cache synchronized with the remote cache all the time.

See Also:
CacheSyncDependency

Constructor Summary
CacheSyncDependency(java.lang.String remoteCacheId, java.lang.String key)
          Initializes a new instance of the CacheSyncDependency with the specified parameters.
CacheSyncDependency(java.lang.String remoteCacheId, java.lang.String key, java.lang.String server, int port)
          Initializes a new instance of the CacheSyncDependency with the specified parameters.
 
Method Summary
 java.lang.String getCacheId()
          The unique Id of the remote cache
 java.lang.String getKey()
          The key of the item in the remote cache with which the local cache item needs to be synchronized.
 int getPort()
          The server port that is used by the clients to connect to the server.
 java.lang.String getServer()
          The name of the server where the remote cache is running.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheSyncDependency

public CacheSyncDependency(java.lang.String remoteCacheId,
                           java.lang.String key)
Initializes a new instance of the CacheSyncDependency with the specified parameters. Internally it tries to initialize the remote cache. If the cache can not be initialized, it throws the exception describing the cause of failure. The remote cache must be running as outproc even if it is on the same machine. The information to connect to the remote cache instance (like server-name and server-port) are picked from the 'jvc-client.conf'.

Parameters:
remoteCacheId - The unique id of the remote cache.
key - The key of the item in the remote cache with which the local cache item will be kept synchronized.

CacheSyncDependency

public CacheSyncDependency(java.lang.String remoteCacheId,
                           java.lang.String key,
                           java.lang.String server,
                           int port)
Initializes a new instance of the CacheSyncDependency with the specified parameters. Internally it tries to initialize the remote cache. If the cache can not be initialized, it throws the exception describing the cause of failure. The remote cache must be running as outproc even if it is on the same machine.

Parameters:
remoteCacheId - The unique id of the remote cache.
key - The key of the item in the remote cache with which the local cache item will be kept synchronized.
server - The name of the server where the remote cache is running.
port - The port used by the client to connect to the server.
Method Detail

getCacheId

public java.lang.String getCacheId()
The unique Id of the remote cache

Returns:
The string cacheid.

getKey

public java.lang.String getKey()
The key of the item in the remote cache with which the local cache item needs to be synchronized.

Returns:
The key.

getServer

public java.lang.String getServer()
The name of the server where the remote cache is running.

Returns:
The name of the server. or the IP.

getPort

public int getPort()
The server port that is used by the clients to connect to the server.

Returns:
The integer value of the port.