Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class DoubleBarrelLRUCache<TKey, TValue>

    Simple concurrent LRU cache, using a "double barrel" approach where two ConcurrentHashMaps record entries.

    At any given time, one hash is primary and the other is secondary. Get(TKey) first checks primary, and if that's a miss, checks secondary. If secondary has the entry, it's promoted to primary (NOTE: the key is cloned at this point). Once primary is full, the secondary is cleared and the two are swapped.

    This is not as space efficient as other possible concurrent approaches (see LUCENE-2075): to achieve perfect LRU(N) it requires 2*N storage. But, this approach is relatively simple and seems in practice to not grow unbounded in size when under hideously high load.

    Note

    This API is for internal purposes only and might change in incompatible ways in the next release.

    Inheritance
    object
    DoubleBarrelLRUCache
    DoubleBarrelLRUCache<TKey, TValue>
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Lucene.Net.Util
    Assembly: Lucene.Net.dll
    Syntax
    public sealed class DoubleBarrelLRUCache<TKey, TValue> : DoubleBarrelLRUCache where TKey : DoubleBarrelLRUCache.CloneableKey
    Type Parameters
    Name Description
    TKey
    TValue

    Constructors

    DoubleBarrelLRUCache(int)

    Simple concurrent LRU cache, using a "double barrel" approach where two ConcurrentHashMaps record entries.

    At any given time, one hash is primary and the other is secondary. Get(TKey) first checks primary, and if that's a miss, checks secondary. If secondary has the entry, it's promoted to primary (NOTE: the key is cloned at this point). Once primary is full, the secondary is cleared and the two are swapped.

    This is not as space efficient as other possible concurrent approaches (see LUCENE-2075): to achieve perfect LRU(N) it requires 2*N storage. But, this approach is relatively simple and seems in practice to not grow unbounded in size when under hideously high load.

    Note

    This API is for internal purposes only and might change in incompatible ways in the next release.

    Declaration
    public DoubleBarrelLRUCache(int maxCount)
    Parameters
    Type Name Description
    int maxCount

    Methods

    Get(TKey)

    Simple concurrent LRU cache, using a "double barrel" approach where two ConcurrentHashMaps record entries.

    At any given time, one hash is primary and the other is secondary. Get(TKey) first checks primary, and if that's a miss, checks secondary. If secondary has the entry, it's promoted to primary (NOTE: the key is cloned at this point). Once primary is full, the secondary is cleared and the two are swapped.

    This is not as space efficient as other possible concurrent approaches (see LUCENE-2075): to achieve perfect LRU(N) it requires 2*N storage. But, this approach is relatively simple and seems in practice to not grow unbounded in size when under hideously high load.

    Note

    This API is for internal purposes only and might change in incompatible ways in the next release.

    Declaration
    public TValue Get(TKey key)
    Parameters
    Type Name Description
    TKey key
    Returns
    Type Description
    TValue

    Put(TKey, TValue)

    Simple concurrent LRU cache, using a "double barrel" approach where two ConcurrentHashMaps record entries.

    At any given time, one hash is primary and the other is secondary. Get(TKey) first checks primary, and if that's a miss, checks secondary. If secondary has the entry, it's promoted to primary (NOTE: the key is cloned at this point). Once primary is full, the secondary is cleared and the two are swapped.

    This is not as space efficient as other possible concurrent approaches (see LUCENE-2075): to achieve perfect LRU(N) it requires 2*N storage. But, this approach is relatively simple and seems in practice to not grow unbounded in size when under hideously high load.

    Note

    This API is for internal purposes only and might change in incompatible ways in the next release.

    Declaration
    public void Put(TKey key, TValue value)
    Parameters
    Type Name Description
    TKey key
    TValue value
    Back to top Copyright © 2024 The Apache Software Foundation, Licensed under the Apache License, Version 2.0
    Apache Lucene.Net, Lucene.Net, Apache, the Apache feather logo, and the Apache Lucene.Net project logo are trademarks of The Apache Software Foundation.
    All other marks mentioned may be trademarks or registered trademarks of their respective owners.