Yo dawg! I heard you like cache, so we put a caching mechanism in yo server side cache, so you can cache while you cache!

…but seriously, PLINQO now includes a built in caching mechanism! Big Smile

  • All IQueryable result sets can now be dynamically cached/retrieved right from the query.
  • The cache is accessible via an IQueryable extension method (FromCache), thus the cached objects are not DataContext specific.
  • The cache duration is set at the time of the query, it can be stored for a specific time span or use a sliding expiration.


using (var context = new PetshopDataContext())
// Cache a result set. (A query is made to the DB.)
var birds = context.Product.GetByCategoryId("BIRDS").FromCache().ToList();
// Get a single entity from that cache. (No query is made to the DB.)
var firstBird = context.Product.GetByCategoryId("BIRDS").FromCache().FirstOrDefault();

// Specify number of seconds to cache. (A query is made to the DB.)
var penguin = context.Product.GetByName("Penguin").FromCache(60).FirstOrDefault();
// Get the same result set back as a list. (No query is made to the DB.)
var penguins = context.Product.GetByName("Penguin").FromCache(60).ToList();


This feature is is not yet available in an official PLINQO release, to use
the cache you will have to download the latest PLINQO Nightly

To access the FromCache extension method you must…

  1. Include a reference to the following assemblies…
    1. CodeSmith.Data
    2. System.Data.Linq
    3. System.Data.Services
    4. System.Web
  2. Include a using/import statement for the CodeSmith.Data.Linq namespace.