17 Introduction to Coherence .NET Clients
This chapter includes the following sections:
- Overview of Coherence for .NET
Coherence for .NET allows .NET applications to access Coherence clustered services, including data, data events, and data processing from outside the Coherence cluster. - Configuration and Usage for .NET Clients
Learn the main steps that are required to use Coherence .NET clients.
Parent topic: Creating .NET Extend Clients
Overview of Coherence for .NET
Coherence for .NET consists of a lightweight .NET library that connects to a Coherence*Extend clustered service instance running within the Coherence cluster using a high performance TCP/IP-based communication layer. This library sends all client requests to the Coherence*Extend clustered service which, in turn, responds to client requests by delegating to an actual Coherence clustered service (for example, a Partitioned or Replicated cache service).
An INamedCache
instance is retrieved by using the CacheFactory.GetCache(...)
API call. After it is obtained, a client accesses the INamedCache
in the same way as it would if it were part of the Coherence cluster. The fact that INamedCache
operations are being sent to a remote cluster node (over TCP/IP) is completely transparent to the client application.
Parent topic: Introduction to Coherence .NET Clients
Configuration and Usage for .NET Clients
This section includes instructions for setting up .NET applications to use Coherence. This section includes the following topics:
- General Instructions
- Configuring Coherence*Extend for .NET
- Obtaining a Cache Reference with .NET
- Cleaning Up Resources Associated with a Cache
Parent topic: Introduction to Coherence .NET Clients
General Instructions
You can follow a basic set of steps for creating and using Coherence .NET clients. The general steps include:
-
Launching the .NET client application
Parent topic: Configuration and Usage for .NET Clients
Configuring Coherence*Extend for .NET
Coherence for .NET clients use a specific XML schema for the Coherence cache configuration file. Make sure the cache configuration file uses the following schema:
<cache-config xmlns="http://schemas.tangosol.com/cache" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.tangosol.com/cache assembly://Coherence/Tangosol.Config/cache-config.xsd"> ...
For general instructions on setting up and configuring Coherence*Extend, refer to:
Parent topic: Configuration and Usage for .NET Clients
Obtaining a Cache Reference with .NET
A reference to a configured cache can be obtained by name by using the CacheFactory
class:
INamedCache cache = CacheFactory.GetCache("example-local-cache");
Parent topic: Configuration and Usage for .NET Clients
Cleaning Up Resources Associated with a Cache
INamedCache
instances, including LocalCache
, should be explicitly released by calling the INamedCache.Release
method when they are no longer needed. If the particular INamedCache
is used for the duration of the application, then the resources are cleaned up when the application is shut down or otherwise stops. However, if the instance is only used for a period of time, then the application should call its Release
method when finished using it.
Alternatively, you can leverage the fact that INamedCache
extends IDisposable
and that all cache implementations delegate a call to IDisposable.Dispose
to INamedCache.Release
. If you want to obtain and release a cache instance within a single method, you can do so with a using
block:
using (INamedCache cache = CacheFactory.GetCache("my-cache")) { // use cache as usual }
After the using
block terminates, IDisposable.Dispose
is called on the INamedCache
instance, and all resources associated with it are released.
Parent topic: Configuration and Usage for .NET Clients