ConcurrentCache<TKey, TValue> Class
Use this type instead of ConcurrentDictionary<TKey, TValue> in caching scenarios.
Namespace
Statiq.Common
Interfaces
Base Types
  • object
graph BT Type-->Base0["object"] Type-.->Interface0["IConcurrentCache"] click Interface0 "/api/Statiq.Common/IConcurrentCache" Type-.->Interface1["IReadOnlyDictionary<TKey, TValue>"] Type-.->Interface2["IReadOnlyCollection<KeyValuePair<TKey, TValue>>"] Type-.->Interface3["IEnumerable<KeyValuePair<TKey, TValue>>"] Type-.->Interface4["IEnumerable"] Type["ConcurrentCache<TKey, TValue>"] class Type type-node

Syntax

public class ConcurrentCache<TKey, TValue> : IConcurrentCache, IReadOnlyDictionary<TKey, TValue>, 
    IReadOnlyCollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, 
    IEnumerable

Remarks

See http://reedcopsey.com/2011/01/16/concurrentdictionarytkeytvalue-used-with-lazyt/ and https://andrewlock.net/making-getoradd-on-concurrentdictionary-thread-safe-using-lazy/.

Type Parameters

Name Description
TKey
TValue

Constructors

Name Summary
ConcurrentCache(bool, bool, IEqualityComparer<TKey>) Creates a thread-safe concurrent cache.
ConcurrentCache(bool, bool) Creates a thread-safe concurrent cache.
ConcurrentCache(bool, IEqualityComparer<TKey>) Creates a thread-safe concurrent cache.
ConcurrentCache(bool) Creates a thread-safe concurrent cache.

Properties

Name Property Type Summary
Count int
Keys IEnumerable<TKey>
this[TKey] TValue
Values IEnumerable<TValue>

Methods

Extension Methods

Name Value Summary
Concat<KeyValuePair<TKey, TValue>>(KeyValuePair<TKey, TValue>) IEnumerable<T>
ContainsAnyKeys<TKey, TValue>(IEnumerable<TKey>) bool
Determines whether the dictionary contains all the specified keys.
ContainsAnyKeys<TKey, TValue>(TKey[]) bool
Determines whether the dictionary contains all the specified keys.
ContainsKeys<TKey, TValue>(IEnumerable<TKey>) bool
Determines whether the dictionary contains all the specified keys.
ContainsKeys<TKey, TValue>(TKey[]) bool
Determines whether the dictionary contains all the specified keys.
GetNext<KeyValuePair<TKey, TValue>>(KeyValuePair<TKey, TValue>, IEqualityComparer<KeyValuePair<TKey, TValue>>) T
GetNext<KeyValuePair<TKey, TValue>>(KeyValuePair<TKey, TValue>) T
GetPrevious<KeyValuePair<TKey, TValue>>(KeyValuePair<TKey, TValue>, IEqualityComparer<KeyValuePair<TKey, TValue>>) T
GetPrevious<KeyValuePair<TKey, TValue>>(KeyValuePair<TKey, TValue>) T
GroupByMany<KeyValuePair<TKey, TValue>, TKey, TElement>(Func<KeyValuePair<TKey, TValue>, IEnumerable<TKey>>, Func<KeyValuePair<TKey, TValue>, TElement>, IEqualityComparer<TKey>) IEnumerable<IGrouping<TKey, TElement>>
Groups the elements of a sequence according to a specified key selector function that returns a sequence of keys. The keys are compared by using a comparer and each group's elements are projected by using a specified function.
GroupByMany<KeyValuePair<TKey, TValue>, TKey, TElement>(Func<KeyValuePair<TKey, TValue>, IEnumerable<TKey>>, Func<KeyValuePair<TKey, TValue>, TElement>) IEnumerable<IGrouping<TKey, TElement>>
Groups the elements of a sequence according to a specified key selector function that returns a sequence of keys and projects the elements for each group by using a specified function.
GroupByMany<KeyValuePair<TKey, TValue>, TKey>(Func<KeyValuePair<TKey, TValue>, IEnumerable<TKey>>, IEqualityComparer<TKey>) IEnumerable<IGrouping<TKey, TSource>>
Groups the elements of a sequence according to a specified key selector function that returns a sequence of keys and compares the keys by using a specified comparer.
GroupByMany<KeyValuePair<TKey, TValue>, TKey>(Func<KeyValuePair<TKey, TValue>, IEnumerable<TKey>>) IEnumerable<IGrouping<TKey, TSource>>
Groups the elements of a sequence according to a specified key selector function that returns a sequence of keys.
GroupByManyToMany<KeyValuePair<TKey, TValue>, TKey, TElement>(Func<KeyValuePair<TKey, TValue>, IEnumerable<TKey>>, Func<KeyValuePair<TKey, TValue>, IEnumerable<TElement>>, IEqualityComparer<TKey>) IEnumerable<IGrouping<TKey, TElement>>
Groups the elements of a sequence according to a specified key selector function that returns a sequence of keys. The keys are compared by using a comparer and each group's elements are projected by using a specified function that returns a sequence of elements.
GroupByManyToMany<KeyValuePair<TKey, TValue>, TKey, TElement>(Func<KeyValuePair<TKey, TValue>, IEnumerable<TKey>>, Func<KeyValuePair<TKey, TValue>, IEnumerable<TElement>>) IEnumerable<IGrouping<TKey, TElement>>
Groups the elements of a sequence according to a specified key selector function that returns a sequence of keys and projects the elements for each group by using a specified function that returns a sequence of elements.
ParallelForEachAsync<KeyValuePair<TKey, TValue>>(Func<KeyValuePair<TKey, TValue>, Task>, CancellationToken) Task
ParallelSelectAsync<KeyValuePair<TKey, TValue>, TResult>(Func<KeyValuePair<TKey, TValue>, Task<TResult>>, CancellationToken) Task<IEnumerable<TResult>>
Invokes an async selector in parallel.
ParallelSelectManyAsync<KeyValuePair<TKey, TValue>, TResult>(Func<KeyValuePair<TKey, TValue>, Task<IEnumerable<TResult>>>, CancellationToken) Task<IEnumerable<TResult>>
Invokes an async selector that returns multiple results in parallel.
ParallelWhereAsync<KeyValuePair<TKey, TValue>>(Func<KeyValuePair<TKey, TValue>, Task<bool>>, CancellationToken) Task<IEnumerable<TSource>>
RequireKeys<TKey, TValue>(IEnumerable<TKey>) void
Verifies that a dictionary contains all requires keys. An System.ArgumentException will be thrown if the specified keys are not all present in the dictionary.
RequireKeys<TKey, TValue>(TKey[]) void
Verifies that a dictionary contains all requires keys. An System.ArgumentException will be thrown if the specified keys are not all present in the dictionary.
StartsWith<KeyValuePair<TKey, TValue>>(IEnumerable<KeyValuePair<TKey, TValue>>, IEqualityComparer<KeyValuePair<TKey, TValue>>) bool
Determines whether the items starts with the specified values.
StartsWith<KeyValuePair<TKey, TValue>>(IEnumerable<KeyValuePair<TKey, TValue>>) bool
Determines whether the items starts with the specified values.
ThrowIfNull<ConcurrentCache<TKey, TValue>>(string) T
ToDocument<ConcurrentCache<TKey, TValue>>(IContentProvider) IDocument
ToDocument<ConcurrentCache<TKey, TValue>>(IEnumerable<KeyValuePair<string, object>>, IContentProvider) IDocument
ToDocument<ConcurrentCache<TKey, TValue>>(NormalizedPath, IContentProvider) IDocument
ToDocument<ConcurrentCache<TKey, TValue>>(NormalizedPath, IEnumerable<KeyValuePair<string, object>>, IContentProvider) IDocument
ToDocument<ConcurrentCache<TKey, TValue>>(NormalizedPath, NormalizedPath, IContentProvider) IDocument
ToDocument<ConcurrentCache<TKey, TValue>>(NormalizedPath, NormalizedPath, IEnumerable<KeyValuePair<string, object>>, IContentProvider) IDocument
ToDocuments<KeyValuePair<TKey, TValue>>(Func<KeyValuePair<TKey, TValue>, IContentProvider>) IEnumerable<IDocument>
ToDocuments<KeyValuePair<TKey, TValue>>(Func<KeyValuePair<TKey, TValue>, IEnumerable<KeyValuePair<string, object>>>, Func<KeyValuePair<TKey, TValue>, IContentProvider>) IEnumerable<IDocument>
ToDocuments<KeyValuePair<TKey, TValue>>(Func<KeyValuePair<TKey, TValue>, NormalizedPath>, Func<KeyValuePair<TKey, TValue>, IContentProvider>) IEnumerable<IDocument>
ToDocuments<KeyValuePair<TKey, TValue>>(Func<KeyValuePair<TKey, TValue>, NormalizedPath>, Func<KeyValuePair<TKey, TValue>, IEnumerable<KeyValuePair<string, object>>>, Func<KeyValuePair<TKey, TValue>, IContentProvider>) IEnumerable<IDocument>
ToDocuments<KeyValuePair<TKey, TValue>>(Func<KeyValuePair<TKey, TValue>, NormalizedPath>, Func<KeyValuePair<TKey, TValue>, NormalizedPath>, Func<KeyValuePair<TKey, TValue>, IContentProvider>) IEnumerable<IDocument>
ToDocuments<KeyValuePair<TKey, TValue>>(Func<KeyValuePair<TKey, TValue>, NormalizedPath>, Func<KeyValuePair<TKey, TValue>, NormalizedPath>, Func<KeyValuePair<TKey, TValue>, IEnumerable<KeyValuePair<string, object>>>, Func<KeyValuePair<TKey, TValue>, IContentProvider>) IEnumerable<IDocument>
ToLookupMany<KeyValuePair<TKey, TValue>, TKey, TElement>(Func<KeyValuePair<TKey, TValue>, IEnumerable<TKey>>, Func<KeyValuePair<TKey, TValue>, TElement>, IEqualityComparer<TKey>) ILookup<TKey, TElement>
Creates a lookup from a sequence according to a specified key selector function that returns a sequence of keys. The keys are compared by using a comparer and each group's elements are projected by using a specified function.
ToLookupMany<KeyValuePair<TKey, TValue>, TKey, TElement>(Func<KeyValuePair<TKey, TValue>, IEnumerable<TKey>>, Func<KeyValuePair<TKey, TValue>, TElement>) ILookup<TKey, TElement>
Creates a lookup from a sequence according to a specified key selector function that returns a sequence of keys and projects the elements for each group by using a specified function.
ToLookupMany<KeyValuePair<TKey, TValue>, TKey>(Func<KeyValuePair<TKey, TValue>, IEnumerable<TKey>>, IEqualityComparer<TKey>) ILookup<TKey, TSource>
Creates a lookup from a sequence according to a specified key selector function that returns a sequence of keys and compares the keys by using a specified comparer.
ToLookupMany<KeyValuePair<TKey, TValue>, TKey>(Func<KeyValuePair<TKey, TValue>, IEnumerable<TKey>>) ILookup<TKey, TSource>
Creates a lookup from a sequence according to a specified key selector function that returns a sequence of keys.
ToLookupManyToMany<KeyValuePair<TKey, TValue>, TKey, TElement>(Func<KeyValuePair<TKey, TValue>, IEnumerable<TKey>>, Func<KeyValuePair<TKey, TValue>, IEnumerable<TElement>>, IEqualityComparer<TKey>) ILookup<TKey, TElement>
Creates a lookup from a sequence according to a specified key selector function that returns a sequence of keys. The keys are compared by using a comparer and each group's elements are projected by using a specified function that returns a sequence of elements.
ToLookupManyToMany<KeyValuePair<TKey, TValue>, TKey, TElement>(Func<KeyValuePair<TKey, TValue>, IEnumerable<TKey>>, Func<KeyValuePair<TKey, TValue>, IEnumerable<TElement>>) ILookup<TKey, TElement>
Creates a lookup from a sequence according to a specified key selector function that returns a sequence of keys and projects the elements for each group by using a specified function that returns a sequence of elements.
ToStringTable<KeyValuePair<TKey, TValue>>(string[], Func<KeyValuePair<TKey, TValue>, object>[]) string