Cache

Introduction

Cache library allow you to cache the result of a LINQ query, usually in the memory, and re-use the cached result for subsequent calls.

Why Cache?

Common Scenarios:

  • Cache read-only table like countries and states
  • Cache rarely modified table (most libraries allow cache expiration)
  • Cache information related to the user logged

Example

// using Z.EntityFramework.Plus; // Don't forget to include this.
var ctx = new EntitiesContext();

// The first call perform a database round trip
var countries1 = ctx.Countries.FromCache().ToList();

// Subsequent calls will take the value from the memory instead
var countries2 = ctx.Countries.FromCache().ToList();

Supported Libraries

Library Type EF Version Support Doc Features
Z.EntityFramework.Plus FREE EF5
EF6
EF Core
< 1 Day Yes Audit
Batch Delete
Batch Update
Cache
Deferred Query
Filter
Future
Include Filter
Include Optimized
EntityFramework.Cache FREE EF6 < 2 Days No Cache

Unsuported Libraries

Use these libraries at your risk!

Library Type EF Version Support Doc Features
EntityFramework.Extended FREE EF5
EF6
No Yes Audit
Batch Delete
Batch Update
Cache
Future