Class CacheSyncDependency
A client application can have more than one cache instance initialized. CacheSyncDependency keeps the items present in one cache synchronized with the items present in another cache.
Inheritance
Assembly: Alachisoft.NCache.Client.dll
Syntax
[Serializable]
public class CacheSyncDependency : ICompactSerializable, IBinaryProtocolSerializable
Remarks
You can add items with the CacheSyncDependency to your application's cache using the ICache interface and the Insert method.
When you add an item to an application's ICache 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.
Constructors
CacheSyncDependency(String, String)
Initializes a new instance of the CacheSyncDependency with the specified parameters. Internally, it tries to initialize the remote cache. If the cache cannot 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) is picked from the client.ncconf file.
Declaration
public CacheSyncDependency(string remoteCacheId, string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | remoteCacheId | The unique ID of the remote cache. |
System.String | key | The key of the item in the remote cache with which the local cache item will be kept synchronized. |
CacheSyncDependency(String, String, Credentials)
Initializes a new instance of the CacheSyncDependency with the specified parameters. Internally, it tries to initialize the remote cache. If the cache cannot 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.
Declaration
public CacheSyncDependency(string remoteCacheId, string key, Credentials credentials)
Parameters
Type | Name | Description |
---|---|---|
System.String | remoteCacheId | The unique ID of the remote cache. |
System.String | key | The key of the item in the remote cache with which the local cache item will be kept synchronized. |
Credentials | credentials | Credentials containing the User ID and password of the server where the remote cache is running. |
CacheSyncDependency(String, String, ServerInfo)
Initializes a new instance of the CacheSyncDependency with the specified parameters. Internally, it tries to initialize the remote cache. If the cache cannot 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.
Declaration
public CacheSyncDependency(string remoteCacheId, string key, ServerInfo serverInfo)
Parameters
Type | Name | Description |
---|---|---|
System.String | remoteCacheId | The unique ID of the remote cache. |
System.String | key | The key of the item in the remote cache with which the local cache item will be kept synchronized. |
ServerInfo | serverInfo | ServerInfo containing information about the server where the remote cache is running. |
CacheSyncDependency(String, String, ServerInfo, Credentials)
Initializes a new instance of the CacheSyncDependency with the specified parameters. Internally, it tries to initialize the remote cache. If the cache cannot 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.
Declaration
public CacheSyncDependency(string remoteCacheId, string key, ServerInfo serverInfo, Credentials credentials)
Parameters
Type | Name | Description |
---|---|---|
System.String | remoteCacheId | The unique ID of the remote cache. |
System.String | key | The key of the item in the remote cache with which the local cache item will be kept synchronized. |
ServerInfo | serverInfo | ServerInfo containing information about the server where remote cache is running. |
Credentials | credentials | Credentials containing the User ID and password of the server where the remote cache is running. |
Properties
CacheId
The unique ID of the remote cache.
Declaration
public string CacheId { get; }
Property Value
Type | Description |
---|---|
System.String | The unique ID of the remote cache. |
Credential
Specifies the user credentials for user authorization.
Declaration
public Credentials Credential { get; }
Property Value
Type | Description |
---|---|
Credentials | Specifies the user credentials for user authorization. |
Key
The key of the item in the remote cache with which the local cache item needs to be synchronized.
Declaration
public string Key { get; }
Property Value
Type | Description |
---|---|
System.String | The key of the item in the remote cache with which the local cache item needs to be synchronized. |
Password
Specifies the user authorization password.
Declaration
[Obsolete("Please use Credentials property.")]
public byte[] Password { get; }
Property Value
Type | Description |
---|---|
System.Byte[] | Specifies the user authorization password. |
Port
The server port that is used by the clients to connect to the server.
Declaration
public int Port { get; }
Property Value
Type | Description |
---|---|
System.Int32 | Specifies the port of server on which the cache is running. |
Server
The name of the server where the remote cache is running.
Declaration
public string Server { get; }
Property Value
Type | Description |
---|---|
System.String | Specifies the name of server on which the cache is running. |
UserId
Specifies the User ID for user authorization.
Declaration
[Obsolete("Please use Credentials property.")]
public string UserId { get; }
Property Value
Type | Description |
---|---|
System.String | Specifies the User ID for user authorization. |
Methods
Deserialize(CompactReader)
Loads the state from the passed reader object.
Declaration
public void Deserialize(CompactReader reader)
Parameters
Type | Name | Description |
---|---|---|
CompactReader | reader | Base class for the CompactBinaryReader. |
Implements
Serialize(CompactWriter)
Saves the state to the passed reader object.
Declaration
public void Serialize(CompactWriter writer)
Parameters
Type | Name | Description |
---|---|---|
CompactWriter | writer | Base class for the CompactBinaryWriter. |