com.alachisoft.ncache.web.caching
Class NCache

java.lang.Object
  extended by com.alachisoft.ncache.web.caching.NCache

public final class NCache
extends java.lang.Object

Provides static methods and properties to to aid with clustered cache initialization and access. This class cannot be inherited.


Constructor Summary
NCache()
           
 
Method Summary
static CacheCollection getCaches()
          Maintains the list of running caches.
static java.lang.String getConfigPath()
           
static Cache initializeCache(java.lang.String cacheId)
          Initializes the cache based on the cacheid.
static Cache initializeCache(java.lang.String cacheId, CacheInitParams initParams)
           
static Cache initializeCache(java.lang.String cacheId, SecurityParams primary, SecurityParams secondary)
          Initializes the cache represente by the cache id.
static Cache initializeCache(java.lang.String cacheId, java.lang.String clientCacheId)
          Initializes the cache represented by the cache id.
static Cache initializeCache(java.lang.String cacheId, java.lang.String server, int port)
          Initializes the cache represente by the cache id.
static Cache initializeCache(java.lang.String cacheId, java.lang.String server, int port, boolean balanceNodes)
          Initializes the cache represent by the cache id.
static Cache initializeCache(java.lang.String cacheId, java.lang.String server, int port, SecurityParams primary, SecurityParams secondary)
          Initializes the cache represented by the cache id.
static void setConfigPath(java.lang.String path)
          Sets the directory path where the NCache configuration files are placed.
static void setExceptionsEnabled(boolean value)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NCache

public NCache()
Method Detail

getCaches

public static CacheCollection getCaches()
Maintains the list of running caches.

Returns:
the CacheCollection of the currently running caches.

getConfigPath

public static java.lang.String getConfigPath()
Returns:
returns Configuration Path

initializeCache

public static Cache initializeCache(java.lang.String cacheId)
                             throws ConfigurationException,
                                    GeneralFailureException,
                                    CacheException
Initializes the cache based on the cacheid. behaves in the same way as if you have called initializeCache(cacheid, null, 0);

Parameters:
cacheId - The id of the cache to be initialized.
Returns:
The cache instance.
Throws:
CacheException - Thrown incase of any error during intializaing the cache.
ConfigurationException - Thrown when an exception occurs during configuration. Likely causes are badly specified configuration strings.
GeneralFailureException - Thrown when an exception occurs during a clustered operation.

initializeCache

public static Cache initializeCache(java.lang.String cacheId,
                                    CacheInitParams initParams)
                             throws ConfigurationException,
                                    GeneralFailureException,
                                    CacheException
Parameters:
cacheId - The cache id to initialize.
initParams - initialization parameters, Security Credentials and other properties are provided here, if null is provided, default instance of CacheInitParams is used.
Returns:
The cache instance.
Throws:
ConfigurationException
GeneralFailureException
CacheException
See Also:
CacheInitParams

initializeCache

public static Cache initializeCache(java.lang.String cacheId,
                                    SecurityParams primary,
                                    SecurityParams secondary)
                             throws ConfigurationException,
                                    GeneralFailureException,
                                    CacheException
Initializes the cache represente by the cache id. It overrides the configuration.

Parameters:
primary - The primary user credentials. SecurityParams
secondary - The secondary user credentials. These credentials are used incase primary credentials are not authorized. SecurityParams
cacheId - The cache id to initialize.
Returns:
The cache instance.
Throws:
CacheException - Thrown incase of any error during intializing the cache.
ConfigurationException - Thrown when an exception occurs during configuration. Likely causes are badly specified configuration strings.
GeneralFailureException - Thrown when an exception occurs during a clustered operation.

initializeCache

public static Cache initializeCache(java.lang.String cacheId,
                                    java.lang.String clientCacheId)
                             throws ConfigurationException,
                                    GeneralFailureException,
                                    CacheException
Initializes the cache represented by the cache id. It overrides the configuration.

Parameters:
cacheId - The cache id to initialize.
clientCacheId - Name of Inproc ClientCache
Returns:
The cache instance.
Throws:
CacheException - Thrown incase of any error during initializing the cache.
ConfigurationException - Thrown when an exception occurs during configuration. Likely causes are badly specified configuration strings.
GeneralFailureException - Thrown when an exception occurs during a clustered operation.

initializeCache

public static Cache initializeCache(java.lang.String cacheId,
                                    java.lang.String server,
                                    int port)
                             throws ConfigurationException,
                                    GeneralFailureException,
                                    CacheException
Initializes the cache represente by the cache id. It overrides the configuration.

Parameters:
cacheId - The cache id to initialize.
server - The name of the node where the NCache server is running.
port - the port of the NCache server.
Returns:
The cache instance.
Throws:
CacheException - Thrown incase of any error during initializing the cache.
ConfigurationException - Thrown when an exception occurs during configuration. Likely causes are badly specified configuration strings.
GeneralFailureException - Thrown when an exception occurs during a clustered operation.

initializeCache

public static Cache initializeCache(java.lang.String cacheId,
                                    java.lang.String server,
                                    int port,
                                    boolean balanceNodes)
                             throws ConfigurationException,
                                    GeneralFailureException,
                                    CacheException
Initializes the cache represent by the cache id. It overrides the configuration.

Parameters:
cacheId - The cache id to initialize.
server - The name of the node where the NCache server is running.
port - the port of the NCache server.
balanceNodes - true to select the least loaded server, false to connect to the given server anyway.
Returns:
The cache instance.
Throws:
CacheException - Thrown incase of any error during intializing the cache.
ConfigurationException - Thrown when an exception occurs during configuration. Likely causes are badly specified configuration strings.
GeneralFailureException - Thrown when an exception occurs during a clustered operation.

initializeCache

public static Cache initializeCache(java.lang.String cacheId,
                                    java.lang.String server,
                                    int port,
                                    SecurityParams primary,
                                    SecurityParams secondary)
                             throws ConfigurationException,
                                    GeneralFailureException,
                                    CacheException
Initializes the cache represented by the cache id. It overrides the configuration.

Parameters:
primary - The primary user credentials. SecurityParams
secondary - The secondary user credentials. These credentials are used incase primary credentials are not authorized. SecurityParams
cacheId - The cache id to initialize.
server - The name of the node where the NCache server is running.
port - the port of the NCache server.
Returns:
The cache instance.
Throws:
CacheException - Thrown incase of any error during initializing the cache.
ConfigurationException - Thrown when an exception occurs during configuration. Likely causes are badly specified configuration strings.
GeneralFailureException - Thrown when an exception occurs during a clustered operation.

setConfigPath

public static void setConfigPath(java.lang.String path)
Sets the directory path where the NCache configuration files are placed.

Parameters:
path - The directory path of configuration files.

setExceptionsEnabled

public static void setExceptionsEnabled(boolean value)
Parameters:
value - Flag that indicates whether exceptions are enabled or not. If this property is set the Cache object throws exceptions from public operations. If not set no exception is thrown and the operation fails silently. Setting this flag is especially helpful during development phase of application since exceptions provide more information about the specific causes of failure.
See Also:
Cache