System Library Common Framework
Search Results for

    *.Benchmark*,*.Tests*,*.ApiTests*,*.BaseTest*,DelegateJsonConverter,CalleeCancelledRequestException,ClientResponse,ContentType,OutputCachePolicy
    Show / Hide Table of Contents Show / Hide Table of Contents
    NamespaceSystemLibrary.Common.Framework.Extensions SystemLibrary.Common.Framework.Net.dll

    Concurrent dictionary extensions

    ConcurrentDictionaryExtensions

    public static class ConcurrentDictionaryExtensions

    Inheritance
    object
    ConcurrentDictionaryExtensions
    Examples
    Arguments
    X

    Methods

    Get T from a static concurrent dictionary based on a key 'int' or adds it to dictionary before returnal

    Remarks
    X

    The static concurrent dictionary lives as long as application runs

    You are responsible for when to instantiate the dictionary

    Item limit per dictionary is set to 50.000 items, if reached the dictionary is cleaned and starts caching over again

    public static T Cache<T>(this ConcurrentDictionary<int, T> dictionary, int key, Func<T> getItem)

    X
    ConcurrentDictionary<int, string> cache = new ConcurrentDictionary<int, string>();
    var result = cache.Cache(123, () => "Hello world");
    X
    Generic types
    Name Description
    T
    Methods arguments
    Type Name Description
    ConcurrentDictionary<int, T> dictionary
    int key
    Func<T> getItem
    X
    Type Description
    T

    Returns T either from Cache or from the Method

    Get T from a static concurrent dictionary based on a key 'Type' or adds it to dictionary before returning

    Remarks
    X

    The static concurrent dictionary lives as long as application runs

    You are responsible for when to instantiate the dictionary

    Item limit per dictionary is set to 50.000 items, if reached the dictionary is cleaned and starts caching over again

    public static T Cache<T>(this ConcurrentDictionary<int, T> dictionary, Type type, Func<T> getItem)

    X

    Example of a Type passed in, its GetHashCode will be used to store as a Int:

    var type = typeof(Car);
    ConcurrentDictionary<int, string> cache = new ConcurrentDictionary<int, string>();
    var result = cache.Cache(type, () => "Hello world");
    X
    Generic types
    Name Description
    T
    Methods arguments
    Type Name Description
    ConcurrentDictionary<int, T> dictionary
    Type type
    Func<T> getItem
    X
    Type Description
    T

    Returns T either from Cache or from the Method

    Get T from a static concurrent dictionary based on a key 'string' or adds it to dictionary before returnal

    Remarks
    X

    The static concurrent dictionary lives as long as application runs

    You are responsible for when to instantiate the dictionary

    Item limit per dictionary is set to 50.000 items, if reached the dictionary is cleaned and starts caching over again

    public static T Cache<T>(this ConcurrentDictionary<string, T> dictionary, string key, Func<T> getItem)

    X
    Generic types
    Name Description
    T
    Methods arguments
    Type Name Description
    ConcurrentDictionary<string, T> dictionary
    string key
    Func<T> getItem
    X
    Type Description
    T

    Returns T either from Cache or from the Method

    }

    In This Article
    Package: nuget
    Source: github
    Website: System Library Common Framework