Class Cache<T, TCached1, TCached2, 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, TCached1, TCached2, TNonCached> : Object, ICache<T>
Type Parameters
Name | Description |
---|---|
T | Type of the objects kept in the cache. |
TCached1 | Type of the first cacheable component of the cached type. |
TCached2 | Type of the second 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 policies and equality comparers.
Declaration
protected Cache()
Cache(ICache<TCached1>, ICache<TCached2>)
Instantiates the cache with the caches to use for cached components.
Declaration
protected Cache(ICache<TCached1> innerCache1, ICache<TCached2> innerCache2)
Parameters
Type | Name | Description |
---|---|---|
ICache<TCached1> | innerCache1 | The first inner cache. |
ICache<TCached2> | innerCache2 | The second 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<TCached1, TCached2, TNonCached> Deconstruct(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The instance to cache. |
Returns
Type | Description |
---|---|
Deconstructed<TCached1, TCached2, TNonCached> | The deconstructed instance. |
Reconstruct(Deconstructed<TCached1, TCached2, TNonCached>)
Reconstructs an instance of the cached type from its cacheable and non-cacheable components.
Declaration
protected abstract T Reconstruct(Deconstructed<TCached1, TCached2, TNonCached> deconstructed)
Parameters
Type | Name | Description |
---|---|---|
Deconstructed<TCached1, TCached2, TNonCached> | deconstructed | The deconstructed instance. |
Returns
Type | Description |
---|---|
T | The reconstructed instance. |