Class Cache<T, TCached, TNonCached>
Utility for deconstructing objects into cacheable and non-cacheable components and sharing the parts that are cacheable.
Inheritance
Implements
Namespace: System.Memory
Assembly: Nuqleon.Memory.dll
Syntax
public abstract class Cache<T, TCached, TNonCached> : Object, ICache<T>
Type Parameters
Name | Description |
---|---|
T | Type of the objects kept in the cache. |
TCached | Type of the cacheable component of the cached type. |
TNonCached | Type of the non-cacheable component of the cached type. |
Constructors
Cache()
Instantiates the cache with a default cache policy and equality comparer.
Declaration
protected Cache()
Cache(ICache<TCached>)
Instantiates the cache with the cache to use for cached component.
Declaration
protected Cache(ICache<TCached> innerCache)
Parameters
Type | Name | Description |
---|---|---|
ICache<TCached> | innerCache | The inner cache. |
Methods
Create(T)
Deconstructs the instance into cacheable and non-cacheable components, caches the cacheable component, and returns a handle that can be used to reconstruct the original instance.
Declaration
public IDiscardable<T> Create(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The instance to cache. |
Returns
Type | Description |
---|---|
IDiscardable<T> | A handle to reconstruct the original instance. |
Deconstruct(T)
Deconstructs an instance of the cached type into its cacheable and non-cacheable components.
Declaration
protected abstract Deconstructed<TCached, TNonCached> Deconstruct(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The instance to cache. |
Returns
Type | Description |
---|---|
Deconstructed<TCached, TNonCached> | The deconstructed instance. |
Reconstruct(Deconstructed<TCached, TNonCached>)
Reconstructs an instance of the cached type from its cacheable and non-cacheable components.
Declaration
protected abstract T Reconstruct(Deconstructed<TCached, TNonCached> deconstructed)
Parameters
Type | Name | Description |
---|---|---|
Deconstructed<TCached, TNonCached> | deconstructed | The deconstructed instance. |
Returns
Type | Description |
---|---|
T | The reconstructed instance. |