Initializes the instance of Cache for this application. Initializes client cache that keeps synchronized with remote cache.

Namespace: Alachisoft.NCache.Web.Caching
Assembly: Alachisoft.NCache.Web (in Alachisoft.NCache.Web.dll) Version: 4.3.0.0 (4.3.0.0)

Syntax

C#
public static Cache InitializeCache(
	string remoteCacheId,
	string clientCacheId
)
Visual Basic
Public Shared Function InitializeCache ( 
	remoteCacheId As String,
	clientCacheId As String
) As Cache
Visual C++
public:
static Cache^ InitializeCache(
	String^ remoteCacheId, 
	String^ clientCacheId
)

Parameters

remoteCacheId
Type: System..::..String
Level 2 cache id
clientCacheId
Type: System..::..String
Level 1 cache id

Return Value

Type: Cache
Cache instance

Remarks

The remoteCacheId parameter represents the registration/config id of the cache. The Cache object can only be created as outproc. An exception will be thrown otherwise. The clientCacheId parameter represents the registration/config id of the cache. Depending upon the configuration the Cache object is created inproc or outproc.

Examples

This sample shows how to use the InitializeCache(String) method inside a sample Web application.
 Copy imageCopy
public override void Init()
{
    // A remote cache with id 'myReplicatedCache' and client cache with id 'myCache' is already registered.
    try
    {
        Alachisoft.NCache.Web.Caching.Cache theCache = NCache.InitializeCache("myReplicatedCache","myCache");
    }
    catch(Exception e)
    {
        // Cache is not available.
    }
}

Exceptions

ExceptionCondition
System..::..ArgumentNullExceptionremoteCacheId is a null reference (Nothing in Visual Basic).
System..::..ArgumentNullExceptionclientCacheId is a null reference (Nothing in Visual Basic).

See Also