.NET Support in GigaSpaces XAP
February 24th, 2012Introduction
(download PDF version with illustrations)
Some work I did for a client a few months ago started me thinking about distributed caching options for .NET. Among the well known distributed caching products, only NCache was designed specifically for .NET, with Microsoft’s own Velocity project expected to mature into a viable product shortly. Others such as Oracle Coherence, Terracotta with EHCache , VMWare GemFire and GigaSpaces XAP are based on non-.NET (primarily Java) ecosystems, but most of them provide some level of support for .NET applications. This post provides a simple framework for comparing the .NET support provided by these products and a summary of what I found when I began exploring GigaSpaces’ XAP .NET edition.
Framework for Comparison
.NET support can be divided into a three tiered hierarchy:
Tier One – It must be possible for a .NET client program to store .NET objects to the cache, retrieve them from the cache, and operate on them. This is the sine qua non of .NET support in a caching product.
Tier Two – For caching products that allow the user (developer) to implement server-side processing that is closely integrated with the cache, the second tier of .NET support lets the developer implement the server-side logic in a .NET language.
Tier Three – A caching product could be implemented entirely in a .NET language and be fully harmonized with the broader .NET ecosystem. As we have already observed, none of the best known products are built this way.
An orthogonal consideration – supported languages – can be applied to all three tiers. Compatibility with one .NET language doesn’t imply compatibility with all .NET languages; cross-language interoperability depends on compliance with Microsoft’s Common Language Specification (CLS) http://msdn.microsoft.com/en-us/library/730f1wy3(v=vs.71).aspx. So, although C# is likely to be the language of interest for most organizations that are looking for a .NET-compatible distributed caching solution, it is worth noting whether or not the .NET support provided in these products extends to other .NET languages as well.
GigaSpaces XAP .NET
First, a refresher on XAP: This GigaSpaces product began as a distributed caching framework designed to reduce latency when accessing application data, be highly scalable, and simplify the construction of “real-time” (event-driven) systems. Unlike most caches which are based on the key – value paradigm, GigaSpaces is based on Java spaces, which is an implementation of tuple spaces http://en.wikipedia.org/wiki/Tuple_space. Tuples provide more generalized data matching features than do key – value pairs, and tuple spaces feature strong, built-in concurrency controls.
As new capabilities were added, the XAP framework evolved from a caching system to a full-featured application development and management platform. In addition to highly available caching, XAP now provides several server-side processing options, event notification and distribution, an SLA-based managed execution environment, dynamic scalability, multi-site replication and – of course – .NET support.
In the terminology of the framework described in the previous section, XAP .NET provides tiers one and two functionality, with support for C# and Visual Basic (VB .NET).
Tier One Support
XAP .NET includes a C# API for use when writing a caching client. The API provides classes and methods for creating or connecting to a cache, writing data to the cache, reading data from the cache, and querying or searching the cache for objects that match specific criteria. Transactional and concurrency control features are also available for use when needed.
Tier Two Support
Server side application logic can be implemented for execution on demand or in response to data events or conditions with GigaSpaces .NET. On-demand logic takes the form of remote procedure calls. Processing logic is implemented in C#, as is the interface contract. Clients use features of the C# API to invoke the remote procedures.
Event driven logic can be implemented as either a polling mechanism or an event notification mechanism. The polling conditions or event registration (depending on which mechanism is in use) are specified in C#, as is handler code that receives the result of the polling operation or is notified of the data event.
Note that the client program that triggers the server-side event need not be a .NET program.