DotNetDCache is a simple distributed cache system written entirely in C# 4 using WCF and the TPL. DotNetDCache offers functionality similar to that of memcached but scaled back. The only functions available are Get, Set, Delete, and GetSize. The client API also includes an OutputCacheProvider for use with ASP.NET.

DotNetDCache is composed of two separate solutions: a windows WCF service that acts as a cache server, and a client API for interacting with the available server(s).
  • The server contains a simple cache store and manages items by expiry and cache size. You can install these servers on many computers.
  • The client API includes a configuration section for specifying all the available servers. The client API will weigh each server by its available cache size and distribute the cached items accordingly.

For performance, setting and removing cache items are done asynchronously. And the cache server is designed so that no locking is necessary when getting cache items.

......................................................................................................................................................................................................................................
Usage example:

MyObject myObject = DotNetDCache.Get<MyObject>("myObjectsKey");
if(myObject == null)
{
    myObject = ... // Get myObject from repository
}
DotNetDCache.Put("myObjectsKey", DateTime.Now.AddMinutes(10), myObject); // expires in 10 minutes

Getting Started

To get up and running, open two instances of Visual Studio 2010. In one window open the DotNetDCache client solution and then open the DotNetDCache server solution in the other. Running the server in debug mode will display a console window telling you that the service has started. Running the tests in the DotNetDCacheClient solution will verify that everything's working.

From here you can dig through the code, install the service on as many cache servers as you'd like, and start referencing the DotNetDCacheClient dll in your own projects to start using this cache service. If you want to run the client and server on different machines, you'll have to update the config files to use the correct host and port.

Last edited Mar 26, 2010 at 6:15 PM by ryan_w, version 8