The cache policy to use with the new document.
public CacheItemPolicy CachePolicy { get; set; } public:property CacheItemPolicy^ CachePolicy{CacheItemPolicy^ get()void set(CacheItemPolicy^ value)}
CachePolicy # get and set (CloneDocumentOptions)
The cache policy to use for the new document that determines when the document and its parts are purged. Default value is a default CacheItemPolicy that never expires.
The policy must contain the desired absolute or sliding expiration date for the document and its part.
Using a cache policy does not mean the document will be stored in the cache forever, refer to AutoSaveToCache for more information on how the cache policy is used.
For more information on cloning documents, refer to LEADDocument.Clone.
using Leadtools;using Leadtools.Codecs;using Leadtools.Document.Writer;using Leadtools.Document;using Leadtools.Caching;using Leadtools.Annotations.Engine;using Leadtools.Ocr;using Leadtools.Barcode;using Leadtools.Document.Converter;public void CloneDocumentExample(){var documentUri = new Uri("https://demo.leadtools.com/images/pdf/leadtools.pdf");// Setup a cacheFileCache cache = new FileCache();cache.CacheDirectory = @"c:\cache-dir";string documentId1;string documentId2;// Load a document into the cachevar loadDocumentOptions = new LoadDocumentOptions();loadDocumentOptions.Cache = cache;using (var document1 = DocumentFactory.LoadFromUri(documentUri, loadDocumentOptions)){// Get its document ID and save itdocumentId1 = document1.DocumentId;document1.AutoDeleteFromCache = false;document1.AutoSaveToCache = false;document1.SaveToCache();// Clone it into the same cachevar cloneDocumentOptions = new CloneDocumentOptions();Console.WriteLine("Cache Policy: {0}", cloneDocumentOptions.CachePolicy.AbsoluteExpiration);using (var document2 = document1.Clone(cache, cloneDocumentOptions)){// Get its document ID and save itdocumentId2 = document2.DocumentId;document2.AutoDeleteFromCache = false;document2.AutoSaveToCache = false;document2.SaveToCache();}using (var document3 = DocumentFactory.CloneDocument(cache, documentId1, cloneDocumentOptions)){// Get its document ID and save itdocumentId1 = document3.DocumentId;document3.AutoDeleteFromCache = false;document3.AutoSaveToCache = false;document3.SaveToCache();}}// Ensure both documents are in the cacheDocumentCacheInfo cacheInfo;cacheInfo = DocumentFactory.GetDocumentCacheInfo(cache, documentId1);Debug.Assert(cacheInfo != null);cacheInfo = DocumentFactory.GetDocumentCacheInfo(cache, documentId2);Debug.Assert(cacheInfo != null);// Now delete the first documentvar deleteFromCacheOptions = new LoadFromCacheOptions();deleteFromCacheOptions.Cache = cache;deleteFromCacheOptions.DocumentId = documentId1;DocumentFactory.DeleteFromCache(deleteFromCacheOptions);cacheInfo = DocumentFactory.GetDocumentCacheInfo(cache, documentId1);Debug.Assert(cacheInfo == null);// Or by loading it from the cache, it should be nullvar loadFromCacheOptions = new LoadFromCacheOptions();loadFromCacheOptions.Cache = cache;loadFromCacheOptions.DocumentId = documentId1;using (var document1 = DocumentFactory.LoadFromCache(loadFromCacheOptions)){Debug.Assert(document1 == null);}// And ensure that the cloned document is still usable by loading itloadFromCacheOptions = new LoadFromCacheOptions();loadFromCacheOptions.Cache = cache;loadFromCacheOptions.DocumentId = documentId2;using (var document2 = DocumentFactory.LoadFromCache(loadFromCacheOptions)){Debug.Assert(document2 != null);}// We are done, delete itdeleteFromCacheOptions = new LoadFromCacheOptions();deleteFromCacheOptions.Cache = cache;deleteFromCacheOptions.DocumentId = documentId2;DocumentFactory.DeleteFromCache(deleteFromCacheOptions);}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
