Show / Hide Table of Contents

Class CacheFactory

Factory for the Oracle Coherence™ for .NET product.

Inheritance
object
CacheFactory
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Tangosol.Net
Assembly: Coherence.dll
Syntax
public abstract class CacheFactory
Remarks

One of the most common functions provided by the CacheFactory is ability to obtain an instance of a cache. There are various cache services and cache topologies that are supported by Coherence.

To get a cache reference use the GetCache(string) method.

This approach that has a lot of advantages over service type specific methods described further below because:

  • complex cache topology could be configured declaratively in the cache configuration XML rather then programmaticaly via API;
  • the caller's code could become completely generic and agnostic to the cache topology;
  • the cache topology decision could be deferred and made much later in the development cycle without changing the application code.

When a cache is no longer used, it is preferrable to call ReleaseCache(INamedCache) to release the associated resources. To destroy all instances of the cache across the cluster, use DestroyCache(INamedCache).

Other services:

  • Invocation Invocation service provides the means for invoking and monitoring execution of classes on specified nodes across a cluster.

    The following factory method returns an instance of Invocation service:

    GetService(string)

Properties

ConfigurableCacheFactory

The IConfigurableCacheFactory singleton.

Declaration
public static IConfigurableCacheFactory ConfigurableCacheFactory { get; set; }
Property Value
Type Description
IConfigurableCacheFactory

An instance of IConfigurableCacheFactory.

DefaultCacheConfig

The default XML cache configuration.

Declaration
public static IXmlDocument DefaultCacheConfig { get; set; }
Property Value
Type Description
IXmlDocument

The default XML cache configuration.

DefaultCacheConfigPath

The path to the default XML cache configuration.

Declaration
public static string DefaultCacheConfigPath { get; set; }
Property Value
Type Description
string

The path to the default XML cache configuration.

DefaultCacheConfigResource

The IResource for the default XML cache configuration.

Declaration
public static IResource DefaultCacheConfigResource { get; set; }
Property Value
Type Description
IResource

The IResource for the default XML cache configuration.

DefaultOperationalConfig

The default XML operational configuration.

Declaration
public static IXmlDocument DefaultOperationalConfig { get; set; }
Property Value
Type Description
IXmlDocument

The default XML operational configuration.

DefaultOperationalConfigPath

The path to the default XML operational configuration.

Declaration
public static string DefaultOperationalConfigPath { get; set; }
Property Value
Type Description
string

The path to the default XML operational configuration.

DefaultOperationalConfigResource

The IResource for the default XML operational configuration.

Declaration
public static IResource DefaultOperationalConfigResource { get; set; }
Property Value
Type Description
IResource

The IResource for the default XML operational configuration.

DefaultPofConfig

The default XML POF configuration.

Declaration
public static IXmlDocument DefaultPofConfig { get; set; }
Property Value
Type Description
IXmlDocument

The default XML POF configuration.

DefaultPofConfigPath

The path to the default XML POF configuration.

Declaration
public static string DefaultPofConfigPath { get; set; }
Property Value
Type Description
string

The path to the default XML POF configuration.

DefaultPofConfigResource

The IResource for the default XML POF configuration.

Declaration
public static IResource DefaultPofConfigResource { get; set; }
Property Value
Type Description
IResource

The IResource for the default XML POF configuration.

Methods

Configure(string, string)

Configure the CacheFactory.

Declaration
public static void Configure(string cacheConfig, string coherenceConfig)
Parameters
Type Name Description
string cacheConfig

An optional path to a file that conforms to cache-config.xsd.

string coherenceConfig

An optional path to a file that conforms to coherence.xsd.

Configure(IResource, IResource)

Configure the CacheFactory.

Declaration
public static void Configure(IResource cacheConfig, IResource coherenceConfig)
Parameters
Type Name Description
IResource cacheConfig

An optional location of a resource that conforms to cache-config.xsd.

IResource coherenceConfig

An optional location of a resource that conforms to coherence.xsd.

Configure(IConfigurableCacheFactory, IOperationalContext)

Configure the CacheFactory.

Declaration
public static void Configure(IConfigurableCacheFactory factory, IOperationalContext ctx)
Parameters
Type Name Description
IConfigurableCacheFactory factory

The rquired singleton IConfigurableCacheFactory.

IOperationalContext ctx

An optional IOperationalContext that contains operational configuration information.

Configure(IXmlElement, IXmlElement)

Configure the CacheFactory.

Declaration
public static void Configure(IXmlElement xmlCache, IXmlElement xmlCoherence)
Parameters
Type Name Description
IXmlElement xmlCache

An optional IXmlElement that conforms to cache-config.xsd.

IXmlElement xmlCoherence

An optional IXmlElement that conforms to coherence.xsd.

DestroyCache(INamedCache)

Releases and destroys the specified INamedCache.

Declaration
public static void DestroyCache(INamedCache cache)
Parameters
Type Name Description
INamedCache cache

The INamedCache object to be destroyed.

Remarks

Warning: This method is used to completely destroy the specified cache across the cluster. All references in the entire cluster to this cache will be invalidated, the cached data will be cleared, and all resources will be released.

See Also
DestroyCache(INamedCache)
ReleaseCache(INamedCache)

GetCache(string)

Return an instance of a cache configured by the current ConfigurableCacheFactory.

Declaration
public static INamedCache GetCache(string name)
Parameters
Type Name Description
string name

Cache name (unique for a given configurable cache factory). If the INamedCache with the specified name already exists, a reference to the same object will be returned.

Returns
Type Description
INamedCache

The INamedCache object.

Remarks

This helper method is a simple wrapper around EnsureCache(string) method.

GetService(string)

Return an instance of a service configured by the current ConfigurableCacheFactory.

Declaration
public static IService GetService(string name)
Parameters
Type Name Description
string name

Service name (unique for a given configurable cache factory). If the IService with the specified name already exists, a reference to the same object will be returned.

Returns
Type Description
IService

The IService object.

Remarks

This helper method is a simple wrapper around the EnsureService(string) method.

IsLogEnabled(LogLevel)

Return true if the Logger would log a message with the given log level.

Declaration
public static bool IsLogEnabled(CacheFactory.LogLevel level)
Parameters
Type Name Description
CacheFactory.LogLevel level

CacheFactory.LogLevel value.

Returns
Type Description
bool

Whether the Logger would log a message with the given log level.

Log(Exception, LogLevel)

Log an exception using Coherence logging facility which is driven by the "logging-config" element located in the coherence-config.xml configuration file.

Declaration
public static void Log(Exception exc, CacheFactory.LogLevel severity)
Parameters
Type Name Description
Exception exc

An exception to log.

CacheFactory.LogLevel severity

The severity of the logged message.

Log(string, Exception, LogLevel)

Log a message and exception using Coherence logging facility which is driven by the "logging-config" element located in the coherence-config.xml configuration file.

Declaration
public static void Log(string message, Exception exc, CacheFactory.LogLevel severity)
Parameters
Type Name Description
string message

A message to log.

Exception exc

An exception to log.

CacheFactory.LogLevel severity

The severity of the logged message.

Log(string, LogLevel)

Log a message using Coherence logging facility which is driven by the "logging-config" element located in the coherence-config.xml configuration file.

Declaration
public static void Log(string message, CacheFactory.LogLevel severity)
Parameters
Type Name Description
string message

A message to log.

CacheFactory.LogLevel severity

The severity of the logged message.

PreprocessProp(IXmlElement)

Preprocess the Coherence properties specified either in the application configuration or environment variables. When both are specified, environment varialbe takes the precedence.

Declaration
public static void PreprocessProp(IXmlElement xmlElement)
Parameters
Type Name Description
IXmlElement xmlElement

The XML element to process.

ReleaseCache(INamedCache)

Release local resources associated with the specified instance of the cache.

Declaration
public static void ReleaseCache(INamedCache cache)
Parameters
Type Name Description
INamedCache cache

The INamedCache object to be released.

Remarks

This invalidates a reference obtained by using one of the factory methods (

GetReplicatedCache, GetOptimisticCache
).

Releasing an INamedCache reference makes it no longer usable, but does not affect the content of the cache. In other words, all other references to the cache will still be valid, and the cache data is not affected by releasing the reference.

The reference that is released using this method can no longer be used; any attempt to use the reference will result in an exception.

See Also
ReleaseCache(INamedCache)
DestroyCache(INamedCache)

Shutdown()

Shutdown all services.

Declaration
public static void Shutdown()
In this article
Back to top Copyright © 2000, 2024, Oracle and/or its affiliates.