Class Cache

Class Cache

ja nimityö: Aspose.Imaging Kokoelma: Aspose.Imaging.dll (25.4.0)

Sisältää cache asetuksia.

public static class Cache

Inheritance

object Cache

Perintöjäsenet

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

Examples

Tämä esimerkki osoittaa Aspose.Imaging.Cachen käytön

// 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

Määritetään jakautuneen levyn bytejä.

public static long AllocatedDiskBytesCount { get; }

Omistuksen arvo

long

Examples

Tämä esimerkki osoittaa Aspose.Imaging.Cachen käytön

// 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

Määrittää tallennettuja muistin bytejä.

public static long AllocatedMemoryBytesCount { get; }

Omistuksen arvo

long

Examples

Tämä esimerkki osoittaa Aspose.Imaging.Cachen käytön

// 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

Saa tai asettaa cache-laatikko.

public static string CacheFolder { get; set; }

Omistuksen arvo

string

CacheType

Saa tai asettaa käytetyn kaasin järjestelmän.

public static CacheType CacheType { get; set; }

Omistuksen arvo

CacheType

Examples

Tämä esimerkki osoittaa Aspose.Imaging.Cachen käytön

// 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

Saat tai asetat arvon, joka osoittaa, onko uudelleenluokitus tarkka vai ei. Jos uudelleenluokitus ei ole tarkka, suorituskyvyn olisi oltava korkeampi.

public static bool ExactReallocateOnly { get; set; }

Omistuksen arvo

bool

Examples

Tämä esimerkki osoittaa Aspose.Imaging.Cachen käytön

// 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

Tarkka uudelleenjakelu suorittaa lisämuistin uudelleenjakelun vain ylärajan määrittämiseen asti.Kun ylitetään yläraja muistiin siirron aikana, tallennetut tiedot kopioidaan levylle mahdollisuuksien mukaan.Kun levyn muistin yläraja ylitetään uudelleenjakelun aikana, asianmukainen poikkeus heitetään.suorituskyvyn olisi oltava korkeampi, jos tämä vaihtoehto on suljettu pois, koska mahdollisuuksien mukaan ei suoriteta lisäkopiointia,Tämä voi kuitenkin johtaa myös muistin tai levyn ylärajojen ylittämiseen.

MaxDiskSpaceForCache

Saat tai asettaa maksimaalisen käytettävissä olevan levyn tilan cache. Määritetty arvo on megabyttien lasku.

public static int MaxDiskSpaceForCache { get; set; }

Omistuksen arvo

int

Examples

Tämä esimerkki osoittaa Aspose.Imaging.Cachen käytön

// 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

Arvo 0 kuluttaa kaikki käytettävissä olevat muisti ja toimii ilman ylärajaa.

MaxMemoryForCache

Saat tai asettaa enimmäismäärän käytettävissä olevaan muistiin tallennettuun muistiin. Määritetty arvo on megabyttien lasku.

public static int MaxMemoryForCache { get; set; }

Omistuksen arvo

int

Examples

Tämä esimerkki osoittaa Aspose.Imaging.Cachen käytön

// 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

Arvo 0 kuluttaa kaikki käytettävissä olevat muisti ja toimii ilman ylärajaa.

Methods

SetDefaults()

Aseta Aspose.Imaging.Cache asetukset oletusarvoon.

public static void SetDefaults()
 Suomi