Alachisoft NCache 4.1 - Online Documentation

Initialize & Dispose Cache

 
JSP, Web Services and J2EE
 
After you have configured the cache, embed NCache API calls in your application to use it. The first thing you need to do is to initialize the cache. The code for initializing the cache is as follows:
 
Using Initialize Method:
 
import com.alachisoft.ncache.web.caching.*;
Cache _cache = NCache.initializeCache("myCache");
 
Security Credentials passing & exceptions:
 
If security is enabled, only an authorized user can perform cache operations, provided those users exist under given domain in LDAP. Login credentials are required to belong to any WINDOWS Server, hosting the user login and running Active Directory services. User can give credential information in overloaded API's or in client.ncconf file. Now security parameters travel in the encrypted form.
 
Providing credentials in API
 
For API's initializeCache, startCache and stopCache, there are overloads that accept User ID and Password as parameters. They are then sent to the server for authentication and authorization.
 
// Initialize the cache.
NCache.initializeCache("myQSReplicatedCache", new Alachisoft.NCache.Web.Security.SecurityParams("john", "john123"), new Alachisoft.NCache.Web.Security.SecurityParams("sam", "sam123"));
 
 
    Initializing Client Cache in Java Environment:
 
NCache is now providing support for Client Cache in Java environment. Users can initialize the Client Cache as follow:
 
    // Initializing the client cache.
   
  Cache _cache = NCache.initializeCache("myCache", "enabled");
 
  To enable client cache in Java environment, users are supposed to specify “enabled” for clientCacheId in client.ncconf:
 
<cache id="clusteredcache" client-cache-id="enabled" client-cache-syncmode="optimistic" default-readthru-provider="" default-writethru-provider="" load-balance="True">
      <server name="20.200.20.14"/>
</cache>
 
 
See Also
 
Copyright © 2005-2012 Alachisoft. All rights reserved.