Class Cache
Numele spaţiului: Aspose.Imaging Asamblare: Aspose.Imaging.dll (25.4.0)
Conține setări cache.
public static class Cache
Inheritance
Membrii moștenitori
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Examples
Acest exemplu demonstrează utilizarea Aspose.Imaging.Cache
// By default the cache folder is set to user's local temp directory.
// You can also specify another cache folder than default like the following:
// Cache.CacheFolder = @"D:\\MyTemp";
// Auto mode is flexible and efficient
Aspose.Imaging.Cache.CacheType = Aspose.Imaging.CacheType.Auto;
// Default value is 0, which means there is no upper limit
Aspose.Imaging.Cache.MaxDiskSpaceForCache = 1073741824; // 1 gigabyte
Aspose.Imaging.Cache.MaxMemoryForCache = 1073741824; // 1 gigabyte
// It is not recommended to change the following property as it may greatly affect the performance
Aspose.Imaging.Cache.ExactReallocateOnly = false;
// At any time you may check how many bytes currently allocated for memory or disk
// cache by examining the following properties
long l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
// Do some image processing as below
Aspose.Imaging.ImageOptions.GifOptions options = new Aspose.Imaging.ImageOptions.GifOptions();
options.Palette = new ColorPalette(new Aspose.Imaging.Color[] { Aspose.Imaging.Color.Red, Aspose.Imaging.Color.Blue, Aspose.Imaging.Color.Black, Aspose.Imaging.Color.White });
options.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream(), true);
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Create(options, 100, 100))
{
Aspose.Imaging.Color[] pixels = new Aspose.Imaging.Color[10000];
for (int i = 0; i < pixels.Length; i++)
{
pixels[i] = Aspose.Imaging.Color.White;
}
image.SavePixels(image.Bounds, pixels);
// after executing the code above there will be allocated 40000 bytes in-memory.
long diskBytes = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long memoryBytes = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
}
// The allocation properties may be used to check whether all Aspose.Imaging objects were properly disposed.
// In case you've forgot to call dispose on some object the cache values will be different than 0.
l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
Properties
AllocatedDiskBytesCount
Obține numărul de byte de disc alocate.
public static long AllocatedDiskBytesCount { get; }
Valoarea proprietății
Examples
Acest exemplu demonstrează utilizarea Aspose.Imaging.Cache
// By default the cache folder is set to user's local temp directory.
// You can also specify another cache folder than default like the following:
// Cache.CacheFolder = @"D:\\MyTemp";
// Auto mode is flexible and efficient
Aspose.Imaging.Cache.CacheType = Aspose.Imaging.CacheType.Auto;
// Default value is 0, which means there is no upper limit
Aspose.Imaging.Cache.MaxDiskSpaceForCache = 1073741824; // 1 gigabyte
Aspose.Imaging.Cache.MaxMemoryForCache = 1073741824; // 1 gigabyte
// It is not recommended to change the following property as it may greatly affect the performance
Aspose.Imaging.Cache.ExactReallocateOnly = false;
// At any time you may check how many bytes currently allocated for memory or disk
// cache by examining the following properties
long l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
// Do some image processing as below
Aspose.Imaging.ImageOptions.GifOptions options = new Aspose.Imaging.ImageOptions.GifOptions();
options.Palette = new ColorPalette(new Aspose.Imaging.Color[] { Aspose.Imaging.Color.Red, Aspose.Imaging.Color.Blue, Aspose.Imaging.Color.Black, Aspose.Imaging.Color.White });
options.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream(), true);
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Create(options, 100, 100))
{
Aspose.Imaging.Color[] pixels = new Aspose.Imaging.Color[10000];
for (int i = 0; i < pixels.Length; i++)
{
pixels[i] = Aspose.Imaging.Color.White;
}
image.SavePixels(image.Bounds, pixels);
// after executing the code above there will be allocated 40000 bytes in-memory.
long diskBytes = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long memoryBytes = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
}
// The allocation properties may be used to check whether all Aspose.Imaging objects were properly disposed.
// In case you've forgot to call dispose on some object the cache values will be different than 0.
l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
AllocatedMemoryBytesCount
Obține numărul de byte alocate în memorie.
public static long AllocatedMemoryBytesCount { get; }
Valoarea proprietății
Examples
Acest exemplu demonstrează utilizarea Aspose.Imaging.Cache
// By default the cache folder is set to user's local temp directory.
// You can also specify another cache folder than default like the following:
// Cache.CacheFolder = @"D:\\MyTemp";
// Auto mode is flexible and efficient
Aspose.Imaging.Cache.CacheType = Aspose.Imaging.CacheType.Auto;
// Default value is 0, which means there is no upper limit
Aspose.Imaging.Cache.MaxDiskSpaceForCache = 1073741824; // 1 gigabyte
Aspose.Imaging.Cache.MaxMemoryForCache = 1073741824; // 1 gigabyte
// It is not recommended to change the following property as it may greatly affect the performance
Aspose.Imaging.Cache.ExactReallocateOnly = false;
// At any time you may check how many bytes currently allocated for memory or disk
// cache by examining the following properties
long l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
// Do some image processing as below
Aspose.Imaging.ImageOptions.GifOptions options = new Aspose.Imaging.ImageOptions.GifOptions();
options.Palette = new ColorPalette(new Aspose.Imaging.Color[] { Aspose.Imaging.Color.Red, Aspose.Imaging.Color.Blue, Aspose.Imaging.Color.Black, Aspose.Imaging.Color.White });
options.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream(), true);
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Create(options, 100, 100))
{
Aspose.Imaging.Color[] pixels = new Aspose.Imaging.Color[10000];
for (int i = 0; i < pixels.Length; i++)
{
pixels[i] = Aspose.Imaging.Color.White;
}
image.SavePixels(image.Bounds, pixels);
// after executing the code above there will be allocated 40000 bytes in-memory.
long diskBytes = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long memoryBytes = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
}
// The allocation properties may be used to check whether all Aspose.Imaging objects were properly disposed.
// In case you've forgot to call dispose on some object the cache values will be different than 0.
l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
CacheFolder
Obține sau stabilește folderul cache.
public static string CacheFolder { get; set; }
Valoarea proprietății
CacheType
Obține sau stabilește schema de cache utilizată.
public static CacheType CacheType { get; set; }
Valoarea proprietății
Examples
Acest exemplu demonstrează utilizarea Aspose.Imaging.Cache
// By default the cache folder is set to user's local temp directory.
// You can also specify another cache folder than default like the following:
// Cache.CacheFolder = @"D:\\MyTemp";
// Auto mode is flexible and efficient
Aspose.Imaging.Cache.CacheType = Aspose.Imaging.CacheType.Auto;
// Default value is 0, which means there is no upper limit
Aspose.Imaging.Cache.MaxDiskSpaceForCache = 1073741824; // 1 gigabyte
Aspose.Imaging.Cache.MaxMemoryForCache = 1073741824; // 1 gigabyte
// It is not recommended to change the following property as it may greatly affect the performance
Aspose.Imaging.Cache.ExactReallocateOnly = false;
// At any time you may check how many bytes currently allocated for memory or disk
// cache by examining the following properties
long l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
// Do some image processing as below
Aspose.Imaging.ImageOptions.GifOptions options = new Aspose.Imaging.ImageOptions.GifOptions();
options.Palette = new ColorPalette(new Aspose.Imaging.Color[] { Aspose.Imaging.Color.Red, Aspose.Imaging.Color.Blue, Aspose.Imaging.Color.Black, Aspose.Imaging.Color.White });
options.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream(), true);
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Create(options, 100, 100))
{
Aspose.Imaging.Color[] pixels = new Aspose.Imaging.Color[10000];
for (int i = 0; i < pixels.Length; i++)
{
pixels[i] = Aspose.Imaging.Color.White;
}
image.SavePixels(image.Bounds, pixels);
// after executing the code above there will be allocated 40000 bytes in-memory.
long diskBytes = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long memoryBytes = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
}
// The allocation properties may be used to check whether all Aspose.Imaging objects were properly disposed.
// In case you've forgot to call dispose on some object the cache values will be different than 0.
l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
ExactReallocateOnly
Obține sau stabilește o valoare care indică dacă redistribuirea ar trebui să fie exactă sau nu. Dacă redistribuirea nu este exactă, performanța ar trebui să fie mai mare.
public static bool ExactReallocateOnly { get; set; }
Valoarea proprietății
Examples
Acest exemplu demonstrează utilizarea Aspose.Imaging.Cache
// By default the cache folder is set to user's local temp directory.
// You can also specify another cache folder than default like the following:
// Cache.CacheFolder = @"D:\\MyTemp";
// Auto mode is flexible and efficient
Aspose.Imaging.Cache.CacheType = Aspose.Imaging.CacheType.Auto;
// Default value is 0, which means there is no upper limit
Aspose.Imaging.Cache.MaxDiskSpaceForCache = 1073741824; // 1 gigabyte
Aspose.Imaging.Cache.MaxMemoryForCache = 1073741824; // 1 gigabyte
// It is not recommended to change the following property as it may greatly affect the performance
Aspose.Imaging.Cache.ExactReallocateOnly = false;
// At any time you may check how many bytes currently allocated for memory or disk
// cache by examining the following properties
long l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
// Do some image processing as below
Aspose.Imaging.ImageOptions.GifOptions options = new Aspose.Imaging.ImageOptions.GifOptions();
options.Palette = new ColorPalette(new Aspose.Imaging.Color[] { Aspose.Imaging.Color.Red, Aspose.Imaging.Color.Blue, Aspose.Imaging.Color.Black, Aspose.Imaging.Color.White });
options.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream(), true);
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Create(options, 100, 100))
{
Aspose.Imaging.Color[] pixels = new Aspose.Imaging.Color[10000];
for (int i = 0; i < pixels.Length; i++)
{
pixels[i] = Aspose.Imaging.Color.White;
}
image.SavePixels(image.Bounds, pixels);
// after executing the code above there will be allocated 40000 bytes in-memory.
long diskBytes = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long memoryBytes = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
}
// The allocation properties may be used to check whether all Aspose.Imaging objects were properly disposed.
// In case you've forgot to call dispose on some object the cache values will be different than 0.
l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
Remarks
Redistribuirea exactă va efectua redistribuirea memoriei suplimentare numai până la limita superioară specificată.Atunci când treceți limita superioară pentru memorie în timpul redistribuirii, datele cache vor fi copiate la disc, dacă este posibil.Atunci când se depășește limita superioară pentru memoria discului în timpul redistribuirii, se aruncă excepția corespunzătoare.Performanța ar trebui să fie mai mare dacă această opțiune este dezactivată, deoarece nu va fi efectuată nici o copie suplimentară dacă este posibil,Cu toate acestea, acest lucru poate duce, de asemenea, la trecerea limitelor superioare specificate pentru memorie sau disc.
MaxDiskSpaceForCache
Obține sau stabilește spațiul maxim de disc disponibil pentru cache. valoarea specificată este numărul de megabite.
public static int MaxDiskSpaceForCache { get; set; }
Valoarea proprietății
Examples
Acest exemplu demonstrează utilizarea Aspose.Imaging.Cache
// By default the cache folder is set to user's local temp directory.
// You can also specify another cache folder than default like the following:
// Cache.CacheFolder = @"D:\\MyTemp";
// Auto mode is flexible and efficient
Aspose.Imaging.Cache.CacheType = Aspose.Imaging.CacheType.Auto;
// Default value is 0, which means there is no upper limit
Aspose.Imaging.Cache.MaxDiskSpaceForCache = 1073741824; // 1 gigabyte
Aspose.Imaging.Cache.MaxMemoryForCache = 1073741824; // 1 gigabyte
// It is not recommended to change the following property as it may greatly affect the performance
Aspose.Imaging.Cache.ExactReallocateOnly = false;
// At any time you may check how many bytes currently allocated for memory or disk
// cache by examining the following properties
long l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
// Do some image processing as below
Aspose.Imaging.ImageOptions.GifOptions options = new Aspose.Imaging.ImageOptions.GifOptions();
options.Palette = new ColorPalette(new Aspose.Imaging.Color[] { Aspose.Imaging.Color.Red, Aspose.Imaging.Color.Blue, Aspose.Imaging.Color.Black, Aspose.Imaging.Color.White });
options.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream(), true);
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Create(options, 100, 100))
{
Aspose.Imaging.Color[] pixels = new Aspose.Imaging.Color[10000];
for (int i = 0; i < pixels.Length; i++)
{
pixels[i] = Aspose.Imaging.Color.White;
}
image.SavePixels(image.Bounds, pixels);
// after executing the code above there will be allocated 40000 bytes in-memory.
long diskBytes = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long memoryBytes = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
}
// The allocation properties may be used to check whether all Aspose.Imaging objects were properly disposed.
// In case you've forgot to call dispose on some object the cache values will be different than 0.
l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
Remarks
Valoarea 0 va consuma toate memoriile disponibile si nu servește ca limită superioara.
MaxMemoryForCache
Obține sau stabilește memoria maximă disponibilă pentru cache în memorie. valoarea specificată este numărul de megabite.
public static int MaxMemoryForCache { get; set; }
Valoarea proprietății
Examples
Acest exemplu demonstrează utilizarea Aspose.Imaging.Cache
// By default the cache folder is set to user's local temp directory.
// You can also specify another cache folder than default like the following:
// Cache.CacheFolder = @"D:\\MyTemp";
// Auto mode is flexible and efficient
Aspose.Imaging.Cache.CacheType = Aspose.Imaging.CacheType.Auto;
// Default value is 0, which means there is no upper limit
Aspose.Imaging.Cache.MaxDiskSpaceForCache = 1073741824; // 1 gigabyte
Aspose.Imaging.Cache.MaxMemoryForCache = 1073741824; // 1 gigabyte
// It is not recommended to change the following property as it may greatly affect the performance
Aspose.Imaging.Cache.ExactReallocateOnly = false;
// At any time you may check how many bytes currently allocated for memory or disk
// cache by examining the following properties
long l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
// Do some image processing as below
Aspose.Imaging.ImageOptions.GifOptions options = new Aspose.Imaging.ImageOptions.GifOptions();
options.Palette = new ColorPalette(new Aspose.Imaging.Color[] { Aspose.Imaging.Color.Red, Aspose.Imaging.Color.Blue, Aspose.Imaging.Color.Black, Aspose.Imaging.Color.White });
options.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream(), true);
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Create(options, 100, 100))
{
Aspose.Imaging.Color[] pixels = new Aspose.Imaging.Color[10000];
for (int i = 0; i < pixels.Length; i++)
{
pixels[i] = Aspose.Imaging.Color.White;
}
image.SavePixels(image.Bounds, pixels);
// after executing the code above there will be allocated 40000 bytes in-memory.
long diskBytes = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long memoryBytes = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
}
// The allocation properties may be used to check whether all Aspose.Imaging objects were properly disposed.
// In case you've forgot to call dispose on some object the cache values will be different than 0.
l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
Remarks
Valoarea 0 va consuma toate memoriile disponibile si nu servește ca limită superioara.
Methods
SetDefaults()
Setarea setărilor Aspose.Imaging.Cache la setările predefinite.
public static void SetDefaults()