About

Nollie is a lightweight, simple to use caching framework for .NET. Nollie let's you cache your .NET objects in a MS SQL-Server database, memory or both for improved performance.

Features

  • Simple to use, one single assembly.
  • Supports caching of .NET objects to MS SQL-Server, memory or both.
  • One cache can consist of multiple partitions.
  • Add, retrieve and remove items from a partition.
  • Cached items can be tagged.
  • Items can be removed from the cache by key, tag or expiry date.
  • Perfect to use for applications running in a non-ASP.NET environment where the System.Web cache is not available.

Getting started

  1. Download the zip with the binary files. Extract it, and copy Nollie.dll to the solution folder.
  2. Add a reference to Nollie.dll in the project that will use caching.
  3. If the database cache will be used,
  4. Follow the code samples below.

Sample code

Create a mixed cache with a single mixed partition that stores the objects in a database and uses an in-memory cache for improved performance:

// Let's create a customer object that we want to cache.
var customer = new Customer();
customer.CustomerId = 1;
customer.Name = "Bill";

// Then we need to create a new cache instance.
var configuration = new CacheConfiguration();
configuration.ConnectionString = ConfigurationManager.ConnectionStrings["Nollie"].ConnectionString;

var cache = CacheFactory.GetMixedCache("Default", configuration);
			
// Each cache instance can contain one or more partitions, so let's create a partition.
var partition = cache.GetMixedPartition("CustomerPartition", 100);

// Now let's cache the customer for 1 hour.
partition.Add("1", customer, null, DateTime.Now.AddHours(1));

// Retrieve the customer.
var customerFromCache = partition.Get<Customer>("1");

// Delete the customer.
partition.RemoveByCacheKey("1");

Last edited Nov 8, 2010 at 7:29 PM by kindblad, version 17