Indicates whether to delete all the entries that belong to this document from the cache when it is disposed.
public bool AutoDeleteFromCache {get; set;}
public:
property bool AutoDeleteFromCache
{
bool get()
void set(bool value)
}
public boolean getAutoDeleteFromCache()
public void setAutoDeleteFromCache(boolean value)
AutoDeleteFromCache # get and set (LEADDocument)
true to delete all the entries that belong to this document from the cache when it is disposed; otherwise, false. The default value is true.
Documents can contain large number of pages and huge amount of data. Storing all this data in the physical memory is not feasible in most situations. Therefore, the LEADDocument class was designed to use an external caching system to store the modified. Refer to DocumentFactory.Cache for more information.
HasCache determines if this document is using the cache system. SaveToCache can be used to save a document to the cache and re-loading it using DocumentFactory.LoadFromCache.
Set AutoDeleteFromCache to true if your application uses cache to speed up processing the document and the object will not be used after it is disposed.
Set AutoDeleteFromCache to false if your application will save the document ID before disposing the document and use it to re-load the document using DocumentFactory.LoadFromCache.
To save the document to the cache, use SaveToCache or set the value of AutoSaveToCache to true before disposing the document.
When dispose is called, the following occur:
If the cache object used supports regions (DefaultCacheCapabilities.CacheRegions), then DeleteRegion.
If the cache does not support regions, then ObjectCache.DeleteAll is called with regionName set to DocumentId and the value of GetCacheKeys passed as the keys.
Refer to Document Toolkit and Caching for more information on how the cache is used with the LEADTOOLS Document library and how to set up optional custom cache provider.
Note that setting this property to a value will update the same value in each child document.
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 DocumentIdExample()
{
var cache = GetCache();
var policy = new CacheItemPolicy();
policy.AbsoluteExpiration = DateTime.Now + new TimeSpan(0, 0, 10);
policy.SlidingExpiration = new TimeSpan(0, 0, 10);
var options = new LoadDocumentOptions();
options.Cache = cache;
options.CachePolicy = policy;
string documentId = null;
using (var document = DocumentFactory.LoadFromFile(Path.Combine(LEAD_VARS.ImagesDir, "Leadtools.pdf"), options))
{
document.AutoDeleteFromCache = false;
documentId = document.DocumentId;
document.SaveToCache();
}
var loadFromCacheOptions = new LoadFromCacheOptions();
loadFromCacheOptions.Cache = cache;
loadFromCacheOptions.DocumentId = documentId;
using (var document = DocumentFactory.LoadFromCache(loadFromCacheOptions))
{
if (null != document)
{
document.AutoDeleteFromCache = true;//will be deleted
}
}
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";
}
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.regex.Pattern;
import org.junit.*;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
import static org.junit.Assert.*;
import leadtools.*;
import leadtools.annotations.engine.*;
import leadtools.barcode.*;
import leadtools.caching.*;
import leadtools.codecs.*;
import leadtools.document.*;
import leadtools.document.DocumentMimeTypes.UserGetDocumentStatusHandler;
import leadtools.document.converter.*;
import leadtools.document.writer.*;
import leadtools.ocr.*;
public void documentIdExample() {
final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images";
FileCache cache = getCache();
CacheItemPolicy policy = new CacheItemPolicy();
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.SECOND, 10);
policy.setAbsoluteExpiration(calendar.getTime());
policy.setSlidingExpiration(10);
LoadDocumentOptions options = new LoadDocumentOptions();
options.setCache(cache);
options.setCachePolicy(policy);
String documentId = null;
LEADDocument document = DocumentFactory.loadFromFile(combine(LEAD_VARS_IMAGES_DIR, "Leadtools.pdf"), options);
document.setAutoDeleteFromCache(false);
documentId = document.getDocumentId();
document.saveToCache();
LoadFromCacheOptions loadFromCacheOptions = new LoadFromCacheOptions();
loadFromCacheOptions.setCache(cache);
loadFromCacheOptions.setDocumentId(documentId);
document = DocumentFactory.loadFromCache(loadFromCacheOptions);
if (null != document) {
document.setAutoDeleteFromCache(true);// will be deleted
}
}
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