Class Cache
Nom dels espais: Aspose.Imaging Assemblea: Aspose.Imaging.dll (25.4.0)
Conté les configuracions de cache.
public static class Cache
Inheritance
Membres heretats
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Examples
Aquest exemple demostra l’ús de 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
Guanya el nombre de bites de disc allotjats.
public static long AllocatedDiskBytesCount { get; }
Valor de la propietat
Examples
Aquest exemple demostra l’ús de 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
Obté el nombre de bytes assignats en memòria.
public static long AllocatedMemoryBytesCount { get; }
Valor de la propietat
Examples
Aquest exemple demostra l’ús de 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
Obté o col·loca la carpeta de cache.
public static string CacheFolder { get; set; }
Valor de la propietat
CacheType
Obté o col·loca el esquema de cache utilitzat.
public static CacheType CacheType { get; set; }
Valor de la propietat
Examples
Aquest exemple demostra l’ús de 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
Obtenir o establir un valor que indiqui si la reallotjament ha de ser exacta o no. En cas de no-alocament, el rendiment ha d’estar més alt.
public static bool ExactReallocateOnly { get; set; }
Valor de la propietat
Examples
Aquest exemple demostra l’ús de 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
La reallotjament exacta realitzarà la realotització de la memòria addicional només fins al límit superior especificat.Quan passi el límit superior per a la memòria durant la reallotjament, les dades caixades es copiaran al disc si és possible.Quan passa el límit superior per a la memòria de disc durant la reallotjament, es llança l’excepció adequada.El rendiment ha de ser més alt si aquesta opció és desactivada ja que no es realitzarà cap còpia addicional si és possible,No obstant això, això també pot conduir a passar els límits superiors especificats per a la memòria o el disc.
MaxDiskSpaceForCache
Obté o estableix l’espai de disc màxim disponible per al cache. El valor especificat és comptar megabits.
public static int MaxDiskSpaceForCache { get; set; }
Valor de la propietat
Examples
Aquest exemple demostra l’ús de 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
El valor de 0 consumeix tota la memòria disponible i no serveix com a límit superior.
MaxMemoryForCache
Obté o estableix la memòria màxima disponible per a la cache en el memori. El valor especificat és comptar megabits.
public static int MaxMemoryForCache { get; set; }
Valor de la propietat
Examples
Aquest exemple demostra l’ús de 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
El valor de 0 consumeix tota la memòria disponible i no serveix com a límit superior.
Methods
SetDefaults()
Configureu les configuracions Aspose.Imaging.Cache a defaults.
public static void SetDefaults()