Class MemoryCacheManager
- Namespace
- Dynamicweb.Caching
- Assembly
- Dynamicweb.Core.dll
public class MemoryCacheManager : ICacheManager, IDisposable
- Inheritance
-
MemoryCacheManager
- Implements
- Inherited Members
Constructors
MemoryCacheManager(MemoryCache)
public MemoryCacheManager(MemoryCache memoryCache)
Parameters
memoryCacheMemoryCache
Properties
AllKeys
Gets all keys currently in the cache.
public IEnumerable<string> AllKeys { get; }
Property Value
- IEnumerable<string>
All keys.
IsValid
Returns true if the cache manager is valid.
public bool IsValid { get; }
Property Value
- bool
trueif cache manager is valid; otherwise,false.
this[string]
Gets or sets the object with the specified key.
[DisallowNull]
public object? this[string key] { get; set; }
Parameters
keystringThe key.
Property Value
- object
Cache entry for the specified key if it exists;
nullotherwise.
Methods
Contains(string)
Determines whether the cache contains an entry with the specified key.
public bool Contains(string key)
Parameters
keystringThe key.
Returns
- bool
trueif a cache entry for the specified key exists; otherwise,false.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Dispose(bool)
protected virtual void Dispose(bool disposing)
Parameters
disposingbool
ForceClear()
Forcefully removes all keys from the cache.
public void ForceClear()
Get(string)
Gets the cache entry for the specified key.
public object? Get(string key)
Parameters
keystringThe key.
Returns
- object
Cache entry for the specified key if it exists;
nullotherwise.
Get<T>(string)
Gets the cache entry for the specified key.
public T? Get<T>(string key)
Parameters
keystringThe key.
Returns
- T
Cache entry for the specified key if it exists;
nullotherwise.
Type Parameters
TThe type of the cache entry object.
Exceptions
- InvalidOperationException
If cache entry is not of type
Tand notnull.
Remove(string)
Removes the cache entry for the specified key.
public virtual void Remove(string key)
Parameters
keystringThe key.
Set(string, object)
Adds or updates the cache entry for the specified key with the given cache item.
public void Set(string key, object cacheItem)
Parameters
Set(string, object, CacheItemPolicy?)
Sets the cache entry for the specified key with the given cache item.
public void Set(string key, object cacheItem, CacheItemPolicy? policy)
Parameters
keystringThe key.
cacheItemobjectThe cache item.
policyCacheItemPolicyThe policy specifying cache behavior.
TryGet<T>(string, out T?)
Tries the get the cache entry for the specified key.
public bool TryGet<T>(string key, out T? value)
Parameters
keystringThe key.
valueTThe value.
Returns
- bool
trueif the Get-operation succeeded,falseotherwise.
Type Parameters
TThe type of the cache entry object.