Skip to content

Extending LazyCache with Redis, Cassandra etc (v0.7.x)

pat macpherson edited this page Apr 1, 2019 · 3 revisions

NOTE: This is for LazyCache 0.7 or lower. For LazyCache v2+ users, you should consider switching away from LazyCache to IDistributedCache

To extend the cache or use a cache library other than MemoryCache such as an Sql Server cache (say) just implement ObjectCache and pass it into the constructor.

     // construct our implementation of ObjectCache
     var customObjectCache = new BespokeCache();

     // Pass it into the lazy cache - 
     var cache = new CachingService(customObjectCache);

     // Now when we use cache it will use customObjectCache

There are several open source implementations of object cache: