Skip to content

Instantly share code, notes, and snippets.

@srkirkland
Created April 22, 2013 18:37

Revisions

  1. srkirkland created this gist Apr 22, 2013.
    16 changes: 16 additions & 0 deletions cachesingeton.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    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();
    }
    }