Show / Hide Table of Contents

    Class Cache<TKey, TValue>

    A base class for cache data structures.

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

    Methods

    | Improve this Doc 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
    System.Boolean

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

    | Improve this Doc 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.

    System.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.

    | Improve this Doc 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.

    | Improve this Doc 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
    System.Boolean

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

    • Improve this Doc
    • View Source
    Back to top Generated by DocFX