Show / Hide Table of Contents

# Class LRUCache<TKey, TValue>

Implements the basic IDictionary interface and adds functionality for controlling the maximum number of entries that can be contained in the Map. When the maximum value is reached the oldest entry is removed so that the max size is never exceeded.

##### Inheritance

System.Object
LRUCache<TKey, TValue>

##### Implements

System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey, TValue>>
System.Collections.IEnumerable

##### Inherited Members

System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()

###### Namespace: Apache.NMS.ActiveMQ.Util

###### Assembly: Apache.NMS.ActiveMQ.dll

##### Syntax

    public class LRUCache<TKey, TValue> : IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable

##### Type Parameters

Name | Description
--- | ---
TKey |
TValue |

### Constructors

| Improve this Doc View Source

#### LRUCache()

##### Declaration

    public LRUCache()

| Improve this Doc View Source

#### LRUCache(Int32)

##### Declaration

    public LRUCache(int maxCacheSize)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int32 | maxCacheSize |

### Fields

| Improve this Doc View Source

#### DEFAULT_MAX_CACHE_SIZE

##### Declaration

    public const int DEFAULT_MAX_CACHE_SIZE = 10000

##### Field Value

Type | Description
--- | ---
System.Int32 |

### Properties

| Improve this Doc View Source

#### Count

##### Declaration

    public int Count { get; }

##### Property Value

Type | Description
--- | ---
System.Int32 |

| Improve this Doc View Source

#### Item[TKey]

##### Declaration

    public TValue this[TKey key] { get; set; }

##### Parameters

Type | Name | Description
--- | --- | ---
TKey | key |

##### Property Value

Type | Description
--- | ---
TValue |

| Improve this Doc View Source

#### Keys

##### Declaration

    public ICollection<TKey> Keys { get; }

##### Property Value

Type | Description
--- | ---
System.Collections.Generic.ICollection<TKey> |

| Improve this Doc View Source

#### MaxCacheSize

##### Declaration

    public int MaxCacheSize { get; set; }

##### Property Value

Type | Description
--- | ---
System.Int32 |

| Improve this Doc View Source

#### Values

##### Declaration

    public ICollection<TValue> Values { get; }

##### Property Value

Type | Description
--- | ---
System.Collections.Generic.ICollection<TValue> |

### Methods

| Improve this Doc View Source

#### Add(TKey, TValue)

##### Declaration

    public void Add(TKey key, TValue val)

##### Parameters

Type | Name | Description
--- | --- | ---
TKey | key |
TValue | val |

| Improve this Doc View Source

#### Clear()

##### Declaration

    public void Clear()

| Improve this Doc View Source

#### ContainsKey(TKey)

##### Declaration

    public bool ContainsKey(TKey key)

##### Parameters

Type | Name | Description
--- | --- | ---
TKey | key |

##### Returns

Type | Description
--- | ---
System.Boolean |

| Improve this Doc View Source

#### ContainsValue(TValue)

##### Declaration

    public bool ContainsValue(TValue theValue)

##### Parameters

Type | Name | Description
--- | --- | ---
TValue | theValue |

##### Returns

Type | Description
--- | ---
System.Boolean |

| Improve this Doc View Source

#### GetEnumerator()

##### Declaration

    public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()

##### Returns

Type | Description
--- | ---
System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<TKey, TValue>> |

| Improve this Doc View Source

#### PutAll(LRUCache<TKey, TValue>)

##### Declaration

    public void PutAll(LRUCache<TKey, TValue> source)

##### Parameters

Type | Name | Description
--- | --- | ---
LRUCache<TKey, TValue> | source |

| Improve this Doc View Source

#### Remove(TKey)

##### Declaration

    public bool Remove(TKey v)

##### Parameters

Type | Name | Description
--- | --- | ---
TKey | v |

##### Returns

Type | Description
--- | ---
System.Boolean |

| Improve this Doc View Source

#### RemoveEldestEntry(KeyValuePair<TKey, TValue>)

##### Declaration

    protected virtual bool RemoveEldestEntry(KeyValuePair<TKey, TValue> eldest)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Collections.Generic.KeyValuePair<TKey, TValue> | eldest |

##### Returns

Type | Description
--- | ---
System.Boolean |

| Improve this Doc View Source

#### TryGetValue(TKey, out TValue)

##### Declaration

    public bool TryGetValue(TKey key, out TValue val)

##### Parameters

Type | Name | Description
--- | --- | ---
TKey | key |
TValue | val |

##### Returns

Type | Description
--- | ---
System.Boolean |

### Explicit Interface Implementations

| Improve this Doc View Source

#### IEnumerable.GetEnumerator()

##### Declaration

    IEnumerator IEnumerable.GetEnumerator()

##### Returns

Type | Description
--- | ---
System.Collections.IEnumerator |

### Implements

System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable