A simple caching layer
C# F# PowerShell Batchfile
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.paket
code
nuget
.gitattributes
.gitignore
License.md
Meerkat.Caching.sln
Meerkat.Caching.snk
README.md
RELEASE_NOTES.md
build.cmd
build.fsx
build.ps1
paket.dependencies
paket.lock

README.md

Meerkat Caching

The Meerkat.Caching library is a simple cache that abstracts an interface from System.Runtime.Caching's MemoryCache

The rationale for this is so we can have a simple caching implementation for using in, say an ASP.NET MVC application, which can then be subsituted for a more advanced cache such as Redis without changing the calls.

We also address the lack of region support in MemoryCache in our wrapper by providing a strategy pattern for constructing a composite key/region key which is then passed to the underlying MemoryCache instance.

NuGet Build status

Welcome to contributions from anyone.

You can see the version history here.

Build the project

  • Windows: Run build.cmd

The tooling should be automatically installed by paket/Fake. The default build will compile and test the project, and also produce a nuget package.

Library License

The library is available under the MIT License, for more information see the License file in the GitHub repository.

Getting Started

The library is intended to be a drop-in replacement for MemoryCache so we have a static class called MemoryObjectCache that wraps it and provides region support. We also provide a static factory class, MemoryObjectCacheFactory to ease the change over.

So originally you might have

    var cache = MemoryCache.Default

You now have

    var cache = MemoryObjectCacheFactory.Default

Under the hood, the factory is just creating a MemoryObjectCache which wraps the MemoryCache and also a RegionKeyStrategy which modifies the keys you add/lookup to provide region support e.g.

    /// <summary>
    /// Get a reference to the default <see cref="MemoryObjectCache"/> instance.
    /// </summary>
    /// <returns></returns>
    public static MemoryObjectCache Default()
    {
        var strategy = new RegionKeyStrategy();
        var cache = MemoryCache.Default;

        return new MemoryObjectCache(cache, strategy);
    }