MemoryCacheExtensions class

namespace: Serenity   assemblySerenity.Net.Core

Contains extensions methods to work with IMemoryCache provider.

public static class MemoryCacheExtensions

Public Members

name description
static Add<TItem>(…) Adds a value to cache with a given key
static Get<TItem>(…) Reads the value with specified key from the local cache. If it doesn't exists in cache, calls the loader function to generate value (from database etc.) and adds it to the cache. If loader returns a null value, it is written to the cache as DBNull.Value.
static RemoveAll(…) Removes all items from the cache (avoid except unit tests).
static TryGet<TItem>(…) Reads the value of given type with specified key from the local cache. If the value doesn't exist or not of given type, it returns null.

See Also