Search Results for

    Show / Hide Table of Contents

    Class Cache<TKey, TValue>

    A base class for cache data structures.

    Inheritance
    object
    Cache<TKey, TValue>
    LruCache<TKey, TValue>
    WeakCache<TKey, TValue>
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Flame.Collections
    Assembly: Flame.dll
    Syntax
    public abstract class Cache<TKey, TValue>
    Type Parameters
    Name Description
    TKey
    TValue

    Methods

    | Edit this page View Source

    ContainsKey(TKey)

    Tests if this cache contains a particular key.

    Declaration
    public virtual bool ContainsKey(TKey key)
    Parameters
    Type Name Description
    TKey key

    The key to look for.

    Returns
    Type Description
    bool

    true if the key is in the cache; false otherwise.

    | Edit this page View Source

    Get(TKey, Func<TKey, TValue>)

    Queries the cache for the value with a particular key. If that value cannot be found, the key is recomputed.

    Declaration
    public virtual TValue Get(TKey key, Func<TKey, TValue> createValue)
    Parameters
    Type Name Description
    TKey key

    The key of the value to query.

    Func<TKey, TValue> createValue

    A callback that creates the value for the key, in case the key was not in the cache.

    Returns
    Type Description
    TValue

    The value for the key.

    | Edit this page View Source

    Insert(TKey, TValue)

    Inserts a new key-value pair into this cache, or overwrites the value for an existing key.

    Declaration
    public abstract void Insert(TKey key, TValue value)
    Parameters
    Type Name Description
    TKey key

    The cached value's key.

    TValue value

    The value to cache.

    | Edit this page View Source

    TryGet(TKey, out TValue)

    Tries to query the cache for the value with a particular key.

    Declaration
    public abstract bool TryGet(TKey key, out TValue value)
    Parameters
    Type Name Description
    TKey key

    The key of the value to query.

    TValue value

    A cached value, if any.

    Returns
    Type Description
    bool

    true if a value for the given key was found in the cache; otherwise, false.

    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX