Class LruCacheStorage<T>
Basic cache storage implementation.
Inheritance
System.Object
LruCacheStorage<T>
Namespace: System.Memory
Assembly: Nuqleon.Memory.dll
Syntax
public sealed class LruCacheStorage<T> : Object, ICacheStorage<T>, IDisposable
Type Parameters
Name | Description |
---|---|
T | Type of the objects kept in the cache. |
Constructors
LruCacheStorage(Int32)
Initializes the cache storage with a default equality comparer.
Declaration
public LruCacheStorage(int size)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | size |
LruCacheStorage(Int32, IEqualityComparer<T>)
Initializes the cache storage with the provided equality comparer.
Declaration
public LruCacheStorage(int size, IEqualityComparer<T> comparer)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | size | The maximum size of the cache. |
System.Collections.Generic.IEqualityComparer<T> | comparer | The equality comparer used to compare cached objects. |
Properties
Count
Gets the current number of entries stored in the cache.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
Dispose()
Disposes the cache storage instance.
Declaration
public void Dispose()
GetEntry(T)
Gets a reference to a cache entry.
Declaration
public IReference<T> GetEntry(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | A value to get a reference for. |
Returns
Type | Description |
---|---|
IReference<T> | A reference to a cache entry. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if the provided value is null. |
ReleaseEntry(IReference<T>)
Releases a reference to a cache entry.
Declaration
public void ReleaseEntry(IReference<T> entry)
Parameters
Type | Name | Description |
---|---|---|
IReference<T> | entry | The reference to release. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if the provided entry is null. |
Implements
System.IDisposable