Class AbstractDocBodyCache<K, TDoc>
Abstract document Cache.
public abstract class AbstractDocBodyCache<K, TDoc> : IDocBodyCache<K, TDoc> where K : notnull where TDoc : BaseDocument<TDoc>
Type Parameters
KTDoc
- Inheritance
-
AbstractDocBodyCache<K, TDoc>
- Implements
-
IDocBodyCache<K, TDoc>
- Inherited Members
- Extension Methods
Constructors
AbstractDocBodyCache(IObjectCache<K, TDoc>, IDocProcessorRepo, IRepo<TDoc>)
Ctor from cache, docProcRepo and docRepo.
public AbstractDocBodyCache(IObjectCache<K, TDoc> cache, IDocProcessorRepo docProcRepo, IRepo<TDoc> docRepo)
Parameters
cacheIObjectCache<K, TDoc>docProcRepoIDocProcessorRepodocRepoIRepo<TDoc>
Properties
DocProcessorRepo
public IDocProcessorRepo DocProcessorRepo { get; }
Property Value
DocRepo
Document IRepo<TEntity>.
public IRepo<TDoc> DocRepo { get; }
Property Value
- IRepo<TDoc>
this[TDoc]
Gets or sets a document body object from the cache with specified tmplDoc as key.
public object? this[TDoc tmplDoc] { get; set; }
Parameters
tmplDocTDoc
Property Value
Remarks
- Setting a value of null evicts any entry with key from the cache.
- Setting a value of of
TDocconverts the document into its body object (usingDocProcessorRepo.GetDocumentProcessorBySid(...))).
Methods
ConvertBodyObj(object)
Convert doc into body object.
protected virtual object ConvertBodyObj(object doc)
Parameters
docobject
Returns
ObtainMissingDocument(TDoc)
Obtain a TDoc not contained in cache from tmplObj.
protected abstract TDoc ObtainMissingDocument(TDoc tmplObj)
Parameters
tmplObjTDoc
Returns
- TDoc
Remarks
If implementation returns null, null is returned from the cache indexer.
WarmUp()
Perform cache warm-up.
public virtual bool WarmUp()
Returns
Remarks
Default implementation is loading all documents of DocRepo.