Cache

Inheritance: java.lang.Object

public final class Cache

يحتوي على إعدادات الذاكرة المؤقتة.

الطرق

طريقةالوصف
getExactReallocateOnly()يحصل على قيمة تُشير إلى ما إذا كان إعادة التخصيص يجب أن تكون دقيقة أم لا.
setExactReallocateOnly(boolean value)يضبط قيمة تُشير إلى ما إذا كان إعادة التخصيص يجب أن تكون دقيقة أم لا.
getCacheFolder()يحصل على مجلد الذاكرة المؤقتة.
setCacheFolder(String value)يضبط مجلد الذاكرة المؤقتة.
getAllocatedMemoryBytesCount()يحصل على عدد البايتات المخصصة في الذاكرة.
getAllocatedDiskBytesCount()يحصل على عدد البايتات المخصصة على القرص.
getMaxMemoryForCache()يحصل على الحد الأقصى للذاكرة المتاحة للذاكرة المؤقتة في الذاكرة.
setMaxMemoryForCache(int value)يضبط الحد الأقصى للذاكرة المتاحة للذاكرة المؤقتة في الذاكرة.
getMaxDiskSpaceForCache()يحصل على الحد الأقصى المتاح لمساحة القرص للتخزين المؤقت.
setMaxDiskSpaceForCache(int value)يضبط الحد الأقصى المتاح لمساحة القرص للتخزين المؤقت.
getCacheType()يحصل على أو يضبط مخطط التخزين المؤقت المستخدم.
setCacheType(int value)يضبط مخطط التخزين المؤقت المستخدم.
setDefaults()يضبط إعدادات Cache إلى القيم الافتراضية.

Example: This example demonstrates how to use com.aspose.imaging.Cache

// بشكل افتراضي يتم تعيين مجلد التخزين المؤقت إلى دليل المؤقت المحلي للمستخدم.
// يمكنك أيضًا تحديد مجلد تخزين مؤقت آخر غير الافتراضي كما يلي:
// com.aspose.imaging.Cache.setCacheFolder("C:\\Temp");

// الوضع التلقائي مرن وفعال
com.aspose.imaging.Cache.setCacheType(com.aspose.imaging.CacheType.Auto);

// القيمة الافتراضية هي 0، مما يعني عدم وجود حد أعلى
com.aspose.imaging.Cache.setMaxDiskSpaceForCache(1073741824); // 1 gigabyte
com.aspose.imaging.Cache.setMaxMemoryForCache(1073741824); // 1 gigabyte

// لا يُنصح بتغيير الخاصية التالية لأنها قد تؤثر بشكل كبير على الأداء
com.aspose.imaging.Cache.setExactReallocateOnly(false);

// في أي وقت يمكنك التحقق من عدد البايتات المخصصة حاليًا للذاكرة أو القرص
// التخزين المؤقت بفحص الخصائص التالية
long l1 = com.aspose.imaging.Cache.getAllocatedDiskBytesCount();
long l2 = com.aspose.imaging.Cache.getAllocatedMemoryBytesCount();

System.out.println("Initial values.");
System.out.println("Allocated disk space, in bytes: " + l1);
System.out.println("Allocated memory, in bytes: " + l2);
System.out.println("--------------------------------------");

// قم ببعض معالجة الصور كما يلي
com.aspose.imaging.imageoptions.GifOptions options = new com.aspose.imaging.imageoptions.GifOptions();
options.setPalette(new com.aspose.imaging.ColorPalette(
        new com.aspose.imaging.Color[]
                {
                        com.aspose.imaging.Color.getRed(),
                        com.aspose.imaging.Color.getBlue(),
                        com.aspose.imaging.Color.getBlack(),
                        com.aspose.imaging.Color.getWhite()
                }));
options.setSource(new com.aspose.imaging.sources.StreamSource(new com.aspose.imaging.system.io.MemoryStream(), true));
com.aspose.imaging.RasterImage image = (com.aspose.imaging.RasterImage) com.aspose.imaging.Image.create(options, 100, 100);
try {
    com.aspose.imaging.Color[] pixels = new com.aspose.imaging.Color[10000];
    for (int i = 0; i < pixels.length; i++) {
        pixels[i] = com.aspose.imaging.Color.getWhite();
    }

    System.out.println("Set the white color for 10000 pixels.");
    image.savePixels(image.getBounds(), pixels);

    // بعد تنفيذ الشيفرة أعلاه سيتم تخصيص 40000 بايت في الذاكرة.
    long diskBytes = com.aspose.imaging.Cache.getAllocatedDiskBytesCount();
    long memoryBytes = com.aspose.imaging.Cache.getAllocatedMemoryBytesCount();
    System.out.println("Allocated disk space, in bytes: " + diskBytes);
    System.out.println("Allocated memory, in bytes: " + memoryBytes);
    System.out.println("--------------------------------------");
} finally {
    System.out.println("Dispose image.");
    image.dispose();
}

// يمكن استخدام خصائص التخصيص للتحقق مما إذا كانت جميع كائنات Aspose.Imaging قد تم تحريرها بشكل صحيح.
// في حال نسيت استدعاء dispose على بعض الكائنات، ستختلف قيم التخزين المؤقت عن 0.
l1 = com.aspose.imaging.Cache.getAllocatedDiskBytesCount();
l2 = com.aspose.imaging.Cache.getAllocatedMemoryBytesCount();
System.out.println("Allocated disk space, in bytes: " + l1);
System.out.println("Allocated memory, in bytes: " + l2);
System.out.println("--------------------------------------");

getExactReallocateOnly()

public static boolean getExactReallocateOnly()

يحصل على قيمة تشير إلى ما إذا كان إعادة التخصيص يجب أن تكون دقيقة أم لا. إذا كانت إعادة التخصيص غير دقيقة، يجب أن يكون الأداء أعلى.

Returns: منطقي - true إذا كانت إعادة التخصيص دقيقة؛ وإلا false.

إعادة التخصيص الدقيقة ستقوم بإعادة تخصيص الذاكرة الإضافية فقط حتى الحد الأعلى المحدد. عند تمرير الحد الأعلى للذاكرة داخلية أثناء إعادة التخصيص، سيتم نسخ البيانات المخزنة مؤقتًا إلى القرص إذا كان ذلك ممكنًا. عند تمرير الحد الأعلى لذاكرة القرص أثناء إعادة التخصيص، يتم إلقاء الاستثناء المناسب. يجب أن يكون الأداء أعلى إذا تم إيقاف هذا الخيار لأنه لن يتم إجراء نسخ إضافي إذا كان ذلك ممكنًا، ومع ذلك قد يؤدي ذلك أيضًا إلى تجاوز الحدود العليا المحددة للذاكرة أو القرص.

setExactReallocateOnly(boolean value)

public static void setExactReallocateOnly(boolean value)

يضبط قيمة تشير إلى ما إذا كان إعادة التخصيص يجب أن تكون دقيقة أم لا. إذا كانت إعادة التخصيص غير دقيقة، يجب أن يكون الأداء أعلى.

Parameters:

معاملنوعالوصف
valueboolean

إعادة التخصيص الدقيقة ستقوم بإعادة تخصيص الذاكرة الإضافية فقط حتى الحد الأعلى المحدد. عند تمرير الحد الأعلى للذاكرة داخلية أثناء إعادة التخصيص، سيتم نسخ البيانات المخزنة مؤقتًا إلى القرص إذا كان ذلك ممكنًا. عند تمرير الحد الأعلى لذاكرة القرص أثناء إعادة التخصيص، يتم إلقاء الاستثناء المناسب. يجب أن يكون الأداء أعلى إذا تم إيقاف هذا الخيار لأنه لن يتم إجراء نسخ إضافي إذا كان ذلك ممكنًا، ومع ذلك قد يؤدي ذلك أيضًا إلى تجاوز الحدود العليا المحددة للذاكرة أو القرص. |

Example: This example demonstrates how to use com.aspose.imaging.Cache

// بشكل افتراضي يتم تعيين مجلد التخزين المؤقت إلى دليل المؤقت المحلي للمستخدم.
// يمكنك أيضًا تحديد مجلد تخزين مؤقت آخر غير الافتراضي كما يلي:
// com.aspose.imaging.Cache.setCacheFolder("C:\\Temp");

// الوضع التلقائي مرن وفعال
com.aspose.imaging.Cache.setCacheType(com.aspose.imaging.CacheType.Auto);

// القيمة الافتراضية هي 0، مما يعني عدم وجود حد أعلى
com.aspose.imaging.Cache.setMaxDiskSpaceForCache(1073741824); // 1 gigabyte
com.aspose.imaging.Cache.setMaxMemoryForCache(1073741824); // 1 gigabyte

// لا يُنصح بتغيير الخاصية التالية لأنها قد تؤثر بشكل كبير على الأداء
com.aspose.imaging.Cache.setExactReallocateOnly(false);

// في أي وقت يمكنك التحقق من عدد البايتات المخصصة حاليًا للذاكرة أو القرص
// التخزين المؤقت بفحص الخصائص التالية
long l1 = com.aspose.imaging.Cache.getAllocatedDiskBytesCount();
long l2 = com.aspose.imaging.Cache.getAllocatedMemoryBytesCount();

System.out.println("Initial values.");
System.out.println("Allocated disk space, in bytes: " + l1);
System.out.println("Allocated memory, in bytes: " + l2);
System.out.println("--------------------------------------");

// قم ببعض معالجة الصور كما يلي
com.aspose.imaging.imageoptions.GifOptions options = new com.aspose.imaging.imageoptions.GifOptions();
options.setPalette(new com.aspose.imaging.ColorPalette(
        new com.aspose.imaging.Color[]
                {
                        com.aspose.imaging.Color.getRed(),
                        com.aspose.imaging.Color.getBlue(),
                        com.aspose.imaging.Color.getBlack(),
                        com.aspose.imaging.Color.getWhite()
                }));
options.setSource(new com.aspose.imaging.sources.StreamSource(new com.aspose.imaging.system.io.MemoryStream(), true));
com.aspose.imaging.RasterImage image = (com.aspose.imaging.RasterImage) com.aspose.imaging.Image.create(options, 100, 100);
try {
    com.aspose.imaging.Color[] pixels = new com.aspose.imaging.Color[10000];
    for (int i = 0; i < pixels.length; i++) {
        pixels[i] = com.aspose.imaging.Color.getWhite();
    }

    System.out.println("Set the white color for 10000 pixels.");
    image.savePixels(image.getBounds(), pixels);

    // بعد تنفيذ الشيفرة أعلاه سيتم تخصيص 40000 بايت في الذاكرة.
    long diskBytes = com.aspose.imaging.Cache.getAllocatedDiskBytesCount();
    long memoryBytes = com.aspose.imaging.Cache.getAllocatedMemoryBytesCount();
    System.out.println("Allocated disk space, in bytes: " + diskBytes);
    System.out.println("Allocated memory, in bytes: " + memoryBytes);
    System.out.println("--------------------------------------");
} finally {
    System.out.println("Dispose image.");
    image.dispose();
}

// يمكن استخدام خصائص التخصيص للتحقق مما إذا كانت جميع كائنات Aspose.Imaging قد تم تحريرها بشكل صحيح.
// في حال نسيت استدعاء dispose على بعض الكائنات، ستختلف قيم التخزين المؤقت عن 0.
l1 = com.aspose.imaging.Cache.getAllocatedDiskBytesCount();
l2 = com.aspose.imaging.Cache.getAllocatedMemoryBytesCount();
System.out.println("Allocated disk space, in bytes: " + l1);
System.out.println("Allocated memory, in bytes: " + l2);
System.out.println("--------------------------------------");

getCacheFolder()

public static String getCacheFolder()

يحصل على مجلد الذاكرة المؤقتة.

Returns: java.lang.String - مجلد التخزين المؤقت.

setCacheFolder(String value)

public static void setCacheFolder(String value)

يضبط مجلد الذاكرة المؤقتة.

Parameters:

معاملنوعالوصف
valuejava.lang.Stringمجلد التخزين المؤقت.

getAllocatedMemoryBytesCount()

public static long getAllocatedMemoryBytesCount()

يحصل على عدد البايتات المخصصة في الذاكرة.

Returns: long - عدد البايتات المخصصة في الذاكرة.

Example: This example demonstrates how to use com.aspose.imaging.Cache

// بشكل افتراضي يتم تعيين مجلد التخزين المؤقت إلى دليل المؤقت المحلي للمستخدم.
// يمكنك أيضًا تحديد مجلد تخزين مؤقت آخر غير الافتراضي كما يلي:
// com.aspose.imaging.Cache.setCacheFolder("C:\\Temp");

// الوضع التلقائي مرن وفعال
com.aspose.imaging.Cache.setCacheType(com.aspose.imaging.CacheType.Auto);

// القيمة الافتراضية هي 0، مما يعني عدم وجود حد أعلى
com.aspose.imaging.Cache.setMaxDiskSpaceForCache(1073741824); // 1 gigabyte
com.aspose.imaging.Cache.setMaxMemoryForCache(1073741824); // 1 gigabyte

// لا يُنصح بتغيير الخاصية التالية لأنها قد تؤثر بشكل كبير على الأداء
com.aspose.imaging.Cache.setExactReallocateOnly(false);

// في أي وقت يمكنك التحقق من عدد البايتات المخصصة حاليًا للذاكرة أو القرص
// التخزين المؤقت بفحص الخصائص التالية
long l1 = com.aspose.imaging.Cache.getAllocatedDiskBytesCount();
long l2 = com.aspose.imaging.Cache.getAllocatedMemoryBytesCount();

System.out.println("Initial values.");
System.out.println("Allocated disk space, in bytes: " + l1);
System.out.println("Allocated memory, in bytes: " + l2);
System.out.println("--------------------------------------");

// قم ببعض معالجة الصور كما يلي
com.aspose.imaging.imageoptions.GifOptions options = new com.aspose.imaging.imageoptions.GifOptions();
options.setPalette(new com.aspose.imaging.ColorPalette(
        new com.aspose.imaging.Color[]
                {
                        com.aspose.imaging.Color.getRed(),
                        com.aspose.imaging.Color.getBlue(),
                        com.aspose.imaging.Color.getBlack(),
                        com.aspose.imaging.Color.getWhite()
                }));
options.setSource(new com.aspose.imaging.sources.StreamSource(new com.aspose.imaging.system.io.MemoryStream(), true));
com.aspose.imaging.RasterImage image = (com.aspose.imaging.RasterImage) com.aspose.imaging.Image.create(options, 100, 100);
try {
    com.aspose.imaging.Color[] pixels = new com.aspose.imaging.Color[10000];
    for (int i = 0; i < pixels.length; i++) {
        pixels[i] = com.aspose.imaging.Color.getWhite();
    }

    System.out.println("Set the white color for 10000 pixels.");
    image.savePixels(image.getBounds(), pixels);

    // بعد تنفيذ الشيفرة أعلاه سيتم تخصيص 40000 بايت في الذاكرة.
    long diskBytes = com.aspose.imaging.Cache.getAllocatedDiskBytesCount();
    long memoryBytes = com.aspose.imaging.Cache.getAllocatedMemoryBytesCount();
    System.out.println("Allocated disk space, in bytes: " + diskBytes);
    System.out.println("Allocated memory, in bytes: " + memoryBytes);
    System.out.println("--------------------------------------");
} finally {
    System.out.println("Dispose image.");
    image.dispose();
}

// يمكن استخدام خصائص التخصيص للتحقق مما إذا كانت جميع كائنات Aspose.Imaging قد تم تحريرها بشكل صحيح.
// في حال نسيت استدعاء dispose على بعض الكائنات، ستختلف قيم التخزين المؤقت عن 0.
l1 = com.aspose.imaging.Cache.getAllocatedDiskBytesCount();
l2 = com.aspose.imaging.Cache.getAllocatedMemoryBytesCount();
System.out.println("Allocated disk space, in bytes: " + l1);
System.out.println("Allocated memory, in bytes: " + l2);
System.out.println("--------------------------------------");

getAllocatedDiskBytesCount()

public static long getAllocatedDiskBytesCount()

يحصل على عدد البايتات المخصصة على القرص.

Returns: long - عدد بايتات القرص المخصصة.

Example: This example demonstrates how to use com.aspose.imaging.Cache

// بشكل افتراضي يتم تعيين مجلد التخزين المؤقت إلى دليل المؤقت المحلي للمستخدم.
// يمكنك أيضًا تحديد مجلد تخزين مؤقت آخر غير الافتراضي كما يلي:
// com.aspose.imaging.Cache.setCacheFolder("C:\\Temp");

// الوضع التلقائي مرن وفعال
com.aspose.imaging.Cache.setCacheType(com.aspose.imaging.CacheType.Auto);

// القيمة الافتراضية هي 0، مما يعني عدم وجود حد أعلى
com.aspose.imaging.Cache.setMaxDiskSpaceForCache(1073741824); // 1 gigabyte
com.aspose.imaging.Cache.setMaxMemoryForCache(1073741824); // 1 gigabyte

// لا يُنصح بتغيير الخاصية التالية لأنها قد تؤثر بشكل كبير على الأداء
com.aspose.imaging.Cache.setExactReallocateOnly(false);

// في أي وقت يمكنك التحقق من عدد البايتات المخصصة حاليًا للذاكرة أو القرص
// التخزين المؤقت بفحص الخصائص التالية
long l1 = com.aspose.imaging.Cache.getAllocatedDiskBytesCount();
long l2 = com.aspose.imaging.Cache.getAllocatedMemoryBytesCount();

System.out.println("Initial values.");
System.out.println("Allocated disk space, in bytes: " + l1);
System.out.println("Allocated memory, in bytes: " + l2);
System.out.println("--------------------------------------");

// قم ببعض معالجة الصور كما يلي
com.aspose.imaging.imageoptions.GifOptions options = new com.aspose.imaging.imageoptions.GifOptions();
options.setPalette(new com.aspose.imaging.ColorPalette(
        new com.aspose.imaging.Color[]
                {
                        com.aspose.imaging.Color.getRed(),
                        com.aspose.imaging.Color.getBlue(),
                        com.aspose.imaging.Color.getBlack(),
                        com.aspose.imaging.Color.getWhite()
                }));
options.setSource(new com.aspose.imaging.sources.StreamSource(new com.aspose.imaging.system.io.MemoryStream(), true));
com.aspose.imaging.RasterImage image = (com.aspose.imaging.RasterImage) com.aspose.imaging.Image.create(options, 100, 100);
try {
    com.aspose.imaging.Color[] pixels = new com.aspose.imaging.Color[10000];
    for (int i = 0; i < pixels.length; i++) {
        pixels[i] = com.aspose.imaging.Color.getWhite();
    }

    System.out.println("Set the white color for 10000 pixels.");
    image.savePixels(image.getBounds(), pixels);

    // بعد تنفيذ الشيفرة أعلاه سيتم تخصيص 40000 بايت في الذاكرة.
    long diskBytes = com.aspose.imaging.Cache.getAllocatedDiskBytesCount();
    long memoryBytes = com.aspose.imaging.Cache.getAllocatedMemoryBytesCount();
    System.out.println("Allocated disk space, in bytes: " + diskBytes);
    System.out.println("Allocated memory, in bytes: " + memoryBytes);
    System.out.println("--------------------------------------");
} finally {
    System.out.println("Dispose image.");
    image.dispose();
}

// يمكن استخدام خصائص التخصيص للتحقق مما إذا كانت جميع كائنات Aspose.Imaging قد تم تحريرها بشكل صحيح.
// في حال نسيت استدعاء dispose على بعض الكائنات، ستختلف قيم التخزين المؤقت عن 0.
l1 = com.aspose.imaging.Cache.getAllocatedDiskBytesCount();
l2 = com.aspose.imaging.Cache.getAllocatedMemoryBytesCount();
System.out.println("Allocated disk space, in bytes: " + l1);
System.out.println("Allocated memory, in bytes: " + l2);
System.out.println("--------------------------------------");

getMaxMemoryForCache()

public static int getMaxMemoryForCache()

يحصل على الحد الأقصى للذاكرة المتاحة للتخزين المؤقت في الذاكرة. القيمة المحددة هي عدد الميغابايت.

Returns: int - الحد الأقصى للذاكرة للتخزين المؤقت.

القيمة 0 ستستهلك كل الذاكرة المتاحة وتعمل كحد أعلى غير موجود.

setMaxMemoryForCache(int value)

public static void setMaxMemoryForCache(int value)

يضبط الحد الأقصى للذاكرة المتاحة للتخزين المؤقت في الذاكرة. القيمة المحددة هي عدد الميغابايت.

Parameters:

معاملنوعالوصف
valueint

القيمة 0 ستستهلك كل الذاكرة المتاحة وتعمل كحد أعلى غير موجود. |

Example: This example demonstrates how to use com.aspose.imaging.Cache

// بشكل افتراضي يتم تعيين مجلد التخزين المؤقت إلى دليل المؤقت المحلي للمستخدم.
// يمكنك أيضًا تحديد مجلد تخزين مؤقت آخر غير الافتراضي كما يلي:
// com.aspose.imaging.Cache.setCacheFolder("C:\\Temp");

// الوضع التلقائي مرن وفعال
com.aspose.imaging.Cache.setCacheType(com.aspose.imaging.CacheType.Auto);

// القيمة الافتراضية هي 0، مما يعني عدم وجود حد أعلى
com.aspose.imaging.Cache.setMaxDiskSpaceForCache(1073741824); // 1 gigabyte
com.aspose.imaging.Cache.setMaxMemoryForCache(1073741824); // 1 gigabyte

// لا يُنصح بتغيير الخاصية التالية لأنها قد تؤثر بشكل كبير على الأداء
com.aspose.imaging.Cache.setExactReallocateOnly(false);

// في أي وقت يمكنك التحقق من عدد البايتات المخصصة حاليًا للذاكرة أو القرص
// التخزين المؤقت بفحص الخصائص التالية
long l1 = com.aspose.imaging.Cache.getAllocatedDiskBytesCount();
long l2 = com.aspose.imaging.Cache.getAllocatedMemoryBytesCount();

System.out.println("Initial values.");
System.out.println("Allocated disk space, in bytes: " + l1);
System.out.println("Allocated memory, in bytes: " + l2);
System.out.println("--------------------------------------");

// قم ببعض معالجة الصور كما يلي
com.aspose.imaging.imageoptions.GifOptions options = new com.aspose.imaging.imageoptions.GifOptions();
options.setPalette(new com.aspose.imaging.ColorPalette(
        new com.aspose.imaging.Color[]
                {
                        com.aspose.imaging.Color.getRed(),
                        com.aspose.imaging.Color.getBlue(),
                        com.aspose.imaging.Color.getBlack(),
                        com.aspose.imaging.Color.getWhite()
                }));
options.setSource(new com.aspose.imaging.sources.StreamSource(new com.aspose.imaging.system.io.MemoryStream(), true));
com.aspose.imaging.RasterImage image = (com.aspose.imaging.RasterImage) com.aspose.imaging.Image.create(options, 100, 100);
try {
    com.aspose.imaging.Color[] pixels = new com.aspose.imaging.Color[10000];
    for (int i = 0; i < pixels.length; i++) {
        pixels[i] = com.aspose.imaging.Color.getWhite();
    }

    System.out.println("Set the white color for 10000 pixels.");
    image.savePixels(image.getBounds(), pixels);

    // بعد تنفيذ الشيفرة أعلاه سيتم تخصيص 40000 بايت في الذاكرة.
    long diskBytes = com.aspose.imaging.Cache.getAllocatedDiskBytesCount();
    long memoryBytes = com.aspose.imaging.Cache.getAllocatedMemoryBytesCount();
    System.out.println("Allocated disk space, in bytes: " + diskBytes);
    System.out.println("Allocated memory, in bytes: " + memoryBytes);
    System.out.println("--------------------------------------");
} finally {
    System.out.println("Dispose image.");
    image.dispose();
}

// يمكن استخدام خصائص التخصيص للتحقق مما إذا كانت جميع كائنات Aspose.Imaging قد تم تحريرها بشكل صحيح.
// في حال نسيت استدعاء dispose على بعض الكائنات، ستختلف قيم التخزين المؤقت عن 0.
l1 = com.aspose.imaging.Cache.getAllocatedDiskBytesCount();
l2 = com.aspose.imaging.Cache.getAllocatedMemoryBytesCount();
System.out.println("Allocated disk space, in bytes: " + l1);
System.out.println("Allocated memory, in bytes: " + l2);
System.out.println("--------------------------------------");

getMaxDiskSpaceForCache()

public static int getMaxDiskSpaceForCache()

يحصل على الحد الأقصى للمساحة المتاحة على القرص للتخزين المؤقت. القيمة المحددة هي عدد الميغابايت.

Returns: int - الحد الأقصى للمساحة المتاحة على القرص للتخزين المؤقت.

القيمة 0 ستستهلك كل الذاكرة المتاحة وتعمل كحد أعلى غير موجود.

setMaxDiskSpaceForCache(int value)

public static void setMaxDiskSpaceForCache(int value)

يضبط الحد الأقصى للمساحة المتاحة على القرص للتخزين المؤقت. القيمة المحددة هي عدد الميغابايت.

Parameters:

معاملنوعالوصف
valueint

القيمة 0 ستستهلك كل الذاكرة المتاحة وتعمل كحد أعلى غير موجود. |

Example: This example demonstrates how to use com.aspose.imaging.Cache

// بشكل افتراضي يتم تعيين مجلد التخزين المؤقت إلى دليل المؤقت المحلي للمستخدم.
// يمكنك أيضًا تحديد مجلد تخزين مؤقت آخر غير الافتراضي كما يلي:
// com.aspose.imaging.Cache.setCacheFolder("C:\\Temp");

// الوضع التلقائي مرن وفعال
com.aspose.imaging.Cache.setCacheType(com.aspose.imaging.CacheType.Auto);

// القيمة الافتراضية هي 0، مما يعني عدم وجود حد أعلى
com.aspose.imaging.Cache.setMaxDiskSpaceForCache(1073741824); // 1 gigabyte
com.aspose.imaging.Cache.setMaxMemoryForCache(1073741824); // 1 gigabyte

// لا يُنصح بتغيير الخاصية التالية لأنها قد تؤثر بشكل كبير على الأداء
com.aspose.imaging.Cache.setExactReallocateOnly(false);

// في أي وقت يمكنك التحقق من عدد البايتات المخصصة حاليًا للذاكرة أو القرص
// التخزين المؤقت بفحص الخصائص التالية
long l1 = com.aspose.imaging.Cache.getAllocatedDiskBytesCount();
long l2 = com.aspose.imaging.Cache.getAllocatedMemoryBytesCount();

System.out.println("Initial values.");
System.out.println("Allocated disk space, in bytes: " + l1);
System.out.println("Allocated memory, in bytes: " + l2);
System.out.println("--------------------------------------");

// قم ببعض معالجة الصور كما يلي
com.aspose.imaging.imageoptions.GifOptions options = new com.aspose.imaging.imageoptions.GifOptions();
options.setPalette(new com.aspose.imaging.ColorPalette(
        new com.aspose.imaging.Color[]
                {
                        com.aspose.imaging.Color.getRed(),
                        com.aspose.imaging.Color.getBlue(),
                        com.aspose.imaging.Color.getBlack(),
                        com.aspose.imaging.Color.getWhite()
                }));
options.setSource(new com.aspose.imaging.sources.StreamSource(new com.aspose.imaging.system.io.MemoryStream(), true));
com.aspose.imaging.RasterImage image = (com.aspose.imaging.RasterImage) com.aspose.imaging.Image.create(options, 100, 100);
try {
    com.aspose.imaging.Color[] pixels = new com.aspose.imaging.Color[10000];
    for (int i = 0; i < pixels.length; i++) {
        pixels[i] = com.aspose.imaging.Color.getWhite();
    }

    System.out.println("Set the white color for 10000 pixels.");
    image.savePixels(image.getBounds(), pixels);

    // بعد تنفيذ الشيفرة أعلاه سيتم تخصيص 40000 بايت في الذاكرة.
    long diskBytes = com.aspose.imaging.Cache.getAllocatedDiskBytesCount();
    long memoryBytes = com.aspose.imaging.Cache.getAllocatedMemoryBytesCount();
    System.out.println("Allocated disk space, in bytes: " + diskBytes);
    System.out.println("Allocated memory, in bytes: " + memoryBytes);
    System.out.println("--------------------------------------");
} finally {
    System.out.println("Dispose image.");
    image.dispose();
}

// يمكن استخدام خصائص التخصيص للتحقق مما إذا كانت جميع كائنات Aspose.Imaging قد تم تحريرها بشكل صحيح.
// في حال نسيت استدعاء dispose على بعض الكائنات، ستختلف قيم التخزين المؤقت عن 0.
l1 = com.aspose.imaging.Cache.getAllocatedDiskBytesCount();
l2 = com.aspose.imaging.Cache.getAllocatedMemoryBytesCount();
System.out.println("Allocated disk space, in bytes: " + l1);
System.out.println("Allocated memory, in bytes: " + l2);
System.out.println("--------------------------------------");

getCacheType()

public static int getCacheType()

يحصل على أو يضبط مخطط التخزين المؤقت المستخدم.

Returns: int - مخطط التخزين المؤقت المستخدم.

setCacheType(int value)

public static void setCacheType(int value)

يضبط مخطط التخزين المؤقت المستخدم.

Parameters:

معاملنوعالوصف
valueintمخطط التخزين المؤقت المستخدم.

Example: This example demonstrates how to use com.aspose.imaging.Cache

// بشكل افتراضي يتم تعيين مجلد التخزين المؤقت إلى دليل المؤقت المحلي للمستخدم.
// يمكنك أيضًا تحديد مجلد تخزين مؤقت آخر غير الافتراضي كما يلي:
// com.aspose.imaging.Cache.setCacheFolder("C:\\Temp");

// الوضع التلقائي مرن وفعال
com.aspose.imaging.Cache.setCacheType(com.aspose.imaging.CacheType.Auto);

// القيمة الافتراضية هي 0، مما يعني عدم وجود حد أعلى
com.aspose.imaging.Cache.setMaxDiskSpaceForCache(1073741824); // 1 gigabyte
com.aspose.imaging.Cache.setMaxMemoryForCache(1073741824); // 1 gigabyte

// لا يُنصح بتغيير الخاصية التالية لأنها قد تؤثر بشكل كبير على الأداء
com.aspose.imaging.Cache.setExactReallocateOnly(false);

// في أي وقت يمكنك التحقق من عدد البايتات المخصصة حاليًا للذاكرة أو القرص
// التخزين المؤقت بفحص الخصائص التالية
long l1 = com.aspose.imaging.Cache.getAllocatedDiskBytesCount();
long l2 = com.aspose.imaging.Cache.getAllocatedMemoryBytesCount();

System.out.println("Initial values.");
System.out.println("Allocated disk space, in bytes: " + l1);
System.out.println("Allocated memory, in bytes: " + l2);
System.out.println("--------------------------------------");

// قم ببعض معالجة الصور كما يلي
com.aspose.imaging.imageoptions.GifOptions options = new com.aspose.imaging.imageoptions.GifOptions();
options.setPalette(new com.aspose.imaging.ColorPalette(
        new com.aspose.imaging.Color[]
                {
                        com.aspose.imaging.Color.getRed(),
                        com.aspose.imaging.Color.getBlue(),
                        com.aspose.imaging.Color.getBlack(),
                        com.aspose.imaging.Color.getWhite()
                }));
options.setSource(new com.aspose.imaging.sources.StreamSource(new com.aspose.imaging.system.io.MemoryStream(), true));
com.aspose.imaging.RasterImage image = (com.aspose.imaging.RasterImage) com.aspose.imaging.Image.create(options, 100, 100);
try {
    com.aspose.imaging.Color[] pixels = new com.aspose.imaging.Color[10000];
    for (int i = 0; i < pixels.length; i++) {
        pixels[i] = com.aspose.imaging.Color.getWhite();
    }

    System.out.println("Set the white color for 10000 pixels.");
    image.savePixels(image.getBounds(), pixels);

    // بعد تنفيذ الشيفرة أعلاه سيتم تخصيص 40000 بايت في الذاكرة.
    long diskBytes = com.aspose.imaging.Cache.getAllocatedDiskBytesCount();
    long memoryBytes = com.aspose.imaging.Cache.getAllocatedMemoryBytesCount();
    System.out.println("Allocated disk space, in bytes: " + diskBytes);
    System.out.println("Allocated memory, in bytes: " + memoryBytes);
    System.out.println("--------------------------------------");
} finally {
    System.out.println("Dispose image.");
    image.dispose();
}

// يمكن استخدام خصائص التخصيص للتحقق مما إذا كانت جميع كائنات Aspose.Imaging قد تم تحريرها بشكل صحيح.
// في حال نسيت استدعاء dispose على بعض الكائنات، ستختلف قيم التخزين المؤقت عن 0.
l1 = com.aspose.imaging.Cache.getAllocatedDiskBytesCount();
l2 = com.aspose.imaging.Cache.getAllocatedMemoryBytesCount();
System.out.println("Allocated disk space, in bytes: " + l1);
System.out.println("Allocated memory, in bytes: " + l2);
System.out.println("--------------------------------------");

setDefaults()

public static void setDefaults()

يضبط إعدادات Cache إلى القيم الافتراضية.