Table of Contents

Class DictionaryCache<TKey, TCachedObject>

Namespace
Dynamicweb.Caching
Assembly
Dynamicweb.Core.dll

In-memory dictionary-cache implementation

public class DictionaryCache<TKey, TCachedObject> : ServiceCache<TKey, TCachedObject>, IDisposable where TKey : IEquatable<TKey>

Type Parameters

TKey

Unique key for cached object

TCachedObject

Cached object

Inheritance
ServiceCache<TKey, TCachedObject>
DictionaryCache<TKey, TCachedObject>
Implements
Inherited Members

Constructors

DictionaryCache(Type)

Constructs a dictionary cache

public DictionaryCache(Type owner)

Parameters

owner Type

Properties

CountInternal

protected override int CountInternal { get; }

Property Value

int

InitializeCache

Lambda makes it possible to initialize all objects in the cache

public override Func<IDictionary<TKey, TCachedObject>>? InitializeCache { get; set; }

Property Value

Func<IDictionary<TKey, TCachedObject>>

Remarks

Useful when cache is often used for ids that do no exist in the database

Methods

ClearCacheInternal()

protected override void ClearCacheInternal()

GetAllValuesInternal()

Gets all values stored in the object cache

protected override IEnumerable<TCachedObject> GetAllValuesInternal()

Returns

IEnumerable<TCachedObject>

values

GetCacheResult(IEnumerable<TKey>)

Gets a cacheresult that contains found objects and the keys that could not be found

public override CacheResult<TKey, TCachedObject> GetCacheResult(IEnumerable<TKey> keys)

Parameters

keys IEnumerable<TKey>

Unique cachekeys

Returns

CacheResult<TKey, TCachedObject>

cacheresult

IsValid()

protected override bool IsValid()

Returns

bool

RemoveFromCache(IEnumerable<TKey>)

protected override void RemoveFromCache(IEnumerable<TKey> keys)

Parameters

keys IEnumerable<TKey>

SetCacheInternal(TKey, TCachedObject)

protected override void SetCacheInternal(TKey key, TCachedObject cachedObject)

Parameters

key TKey
cachedObject TCachedObject
To top