Skip to content

Instantly share code, notes, and snippets.

@srkirkland
Created April 22, 2013 18:37
Show Gist options
  • Save srkirkland/5437393 to your computer and use it in GitHub Desktop.
Save srkirkland/5437393 to your computer and use it in GitHub Desktop.
Singleton for creating a cache factory for Azure Caching. Creates the DataCacheFactory only once and stores it in CacheFactory.Instance. Can then get a desired DataCache by calling CacheFactory.Instance.GetCache("CacheName");
public static class CacheFactory
{
/// <summary>
/// This is a thread-safe, lazy singleton. See http://www.yoda.arachsys.com/csharp/singleton.html
/// for more details about its implementation.
/// </summary>
public static DataCacheFactory Instance
{
get { return Nested.CacheFactory; }
}
private class Nested
{
internal static readonly DataCacheFactory CacheFactory = new DataCacheFactory();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment