Class Cache

Class Cache

Navne til: Aspose.Imaging Sammensætning: Aspose.Imaging.dll (25.4.0)

Indeholder cache indstillinger.

public static class Cache

Inheritance

object Cache

De arvede medlemmer

object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Examples

Dette eksempel viser brugen af 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

Få den tildelte disk byte tælle.

public static long AllocatedDiskBytesCount { get; }

Ejendomsværdi

long

Examples

Dette eksempel viser brugen af 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

Få det tildelte in-memory bytes tal.

public static long AllocatedMemoryBytesCount { get; }

Ejendomsværdi

long

Examples

Dette eksempel viser brugen af 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

Få eller indsætte cache mappen.

public static string CacheFolder { get; set; }

Ejendomsværdi

string

CacheType

Få eller indstille den anvendte cache-system.

public static CacheType CacheType { get; set; }

Ejendomsværdi

CacheType

Examples

Dette eksempel viser brugen af 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

Giver eller sætter en værdi, der angiver, om genfordeling skal være nøjagtig eller ej. Hvis genfordeling ikke er nøjagtig, skal ydeevnen være højere.

public static bool ExactReallocateOnly { get; set; }

Ejendomsværdi

bool

Examples

Dette eksempel viser brugen af 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

Den nøjagtige genfordeling vil udføre genfordeling af ekstra hukommelse kun op til den øverste grænse, der er angivet.Når du passerer den øverste grænse for in-memory under genfordeling, vil de cachede data kopieres til disken, hvis det er muligt.Når du passerer den øverste grænse for diskminne under genfordeling, kastes den relevante undtagelse.Udførelsen skal være højere, hvis denne mulighed er slået af, da der ikke udføres yderligere kopiering, hvis det er muligt,Dette kan dog også føre til at overskride de øvre grænser, der er angivet for hukommelse eller disk.

MaxDiskSpaceForCache

Få eller indstille den maksimale tilgængelige diskplads til cache. Det angivne værdi er megabytes tælle.

public static int MaxDiskSpaceForCache { get; set; }

Ejendomsværdi

int

Examples

Dette eksempel viser brugen af 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

Værdien af 0 forbruger al tilgængelig hukommelse og tjener som ingen øvre grænse.

MaxMemoryForCache

Få eller indstille den maksimale tilgængelige hukommelse for cache i hukommelsen.

public static int MaxMemoryForCache { get; set; }

Ejendomsværdi

int

Examples

Dette eksempel viser brugen af 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

Værdien af 0 forbruger al tilgængelig hukommelse og tjener som ingen øvre grænse.

Methods

SetDefaults()

Indsæt Aspose.Imaging.Cache indstillinger til standard.

public static void SetDefaults()
 Dansk