Cache Service
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
ذاكرة التخزين المؤقت
تسمح هذه الخدمة للنص البرمجي بتخزين النتائج مؤقتًا في ذاكرة التخزين المؤقت، وهي نتائج تستغرق وقتًا في
جلبها أو احتسابها. تكون ذاكرات التخزين المؤقت العامة مخصّصة للعناصر التي لا تعتمد على المستخدم الذي
يصل إلى النص البرمجي. وتكون ذاكرات التخزين المؤقت الخاصة مخصّصة للعناصر الخاصة بالمستخدم،
مثل الإعدادات أو الأنشطة الحديثة.
صفوف
الاسم | وصف قصير |
Cache | مرجع إلى ذاكرة تخزين مؤقت معيّنة. |
CacheService | ذاكرة التخزين المؤقتتسمح لك الخدمة بالوصول إلى ذاكرة تخزين مؤقت لتخزين البيانات على المدى القصير. |
الطُرق
الطريقة | نوع القيمة التي يتم عرضها | وصف قصير |
get(key) | String | تحصل على القيمة المخزّنة مؤقتًا للمفتاح المحدّد، أو null في حال عدم العثور على أي قيمة. |
getAll(keys) | Object | تعرِض هذه الدالة عنصر JavaScript يحتوي على جميع أزواج المفتاح/القيمة التي تم العثور عليها في ذاكرة التخزين المؤقت لمصفوفة من
المفاتيح. |
put(key, value) | void | تُضيف هذه الوظيفة زوج مفتاح/قيمة إلى ذاكرة التخزين المؤقت. |
put(key, value, expirationInSeconds) | void | تُضيف هذه الدالة زوج مفتاح/قيمة إلى ذاكرة التخزين المؤقت، مع وقت انتهاء صلاحية (بالثواني). |
putAll(values) | void | تُضيف مجموعة من أزواج المفتاح/القيمة إلى ذاكرة التخزين المؤقت. |
putAll(values, expirationInSeconds) | void | تُضيف مجموعة من أزواج المفتاح/القيمة إلى ذاكرة التخزين المؤقت، مع وقت انتهاء صلاحية (بالثواني). |
remove(key) | void | تزيل إدخالًا من ذاكرة التخزين المؤقت باستخدام المفتاح المحدَّد. |
removeAll(keys) | void | تزيل مجموعة من الإدخالات من ذاكرة التخزين المؤقت. |
الطُرق
الطريقة | نوع القيمة التي يتم عرضها | وصف قصير |
getDocumentCache() | Cache | تحصل على مثيل ذاكرة التخزين المؤقت الذي يشمل المستند والنص البرمجي الحاليَين. |
getScriptCache() | Cache | تحصل على مثيل ذاكرة التخزين المؤقت على مستوى النص البرمجي. |
getUserCache() | Cache | تحصل على مثيل ذاكرة التخزين المؤقت على مستوى المستخدم والنص البرمجي الحاليَين. |
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eApps Script Cache service provides temporary storage for script results, improving performance by avoiding redundant computations or fetches.\u003c/p\u003e\n"],["\u003cp\u003eTwo types of caches are available: public caches for shared data and private caches for user-specific information.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eCacheService\u003c/code\u003e offers methods to access document, script, or user-scoped caches, while the \u003ccode\u003eCache\u003c/code\u003e class provides methods for data manipulation within a cache instance, like adding, retrieving, and removing entries.\u003c/p\u003e\n"],["\u003cp\u003eCache entries can have optional expiration times, allowing for automatic removal after a specified duration.\u003c/p\u003e\n"]]],[],null,["# Cache Service\n\nCache\n\nThis service allows a script to temporarily cache results that take time to\nfetch/compute. Public caches are for things that are not dependent on which user\nis accessing your script. Private caches are for things which are user-specific,\nlike settings or recent activity.\n\nClasses\n-------\n\n| Name | Brief description |\n|------------------------------------------------------------|---------------------------------------------------------------------------|\n| [Cache](/apps-script/reference/cache/cache) | A reference to a particular cache. |\n| [CacheService](/apps-script/reference/cache/cache-service) | CacheService allows you to access a cache for short term storage of data. |\n\n[Cache](/apps-script/reference/cache/cache)\n-------------------------------------------\n\n### Methods\n\n| Method | Return type | Brief description |\n|-------------------------------------------------------------------------------------------------------|-------------|-----------------------------------------------------------------------------------------------------|\n| [get(key)](/apps-script/reference/cache/cache#get(String)) | `String` | Gets the cached value for the given key, or `null` if none is found. |\n| [getAll(keys)](/apps-script/reference/cache/cache#getAll(String)) | `Object` | Returns a JavaScript Object containing all key/value pairs found in the cache for an array of keys. |\n| [put(key, value)](/apps-script/reference/cache/cache#put(String,String)) | `void` | Adds a key/value pair to the cache. |\n| [put(key, value, expirationInSeconds)](/apps-script/reference/cache/cache#put(String,String,Integer)) | `void` | Adds a key/value pair to the cache, with an expiration time (in seconds). |\n| [putAll(values)](/apps-script/reference/cache/cache#putAll(Object)) | `void` | Adds a set of key/value pairs to the cache. |\n| [putAll(values, expirationInSeconds)](/apps-script/reference/cache/cache#putAll(Object,Integer)) | `void` | Adds a set of key/value pairs to the cache, with an expiration time (in seconds). |\n| [remove(key)](/apps-script/reference/cache/cache#remove(String)) | `void` | Removes an entry from the cache using the given key. |\n| [removeAll(keys)](/apps-script/reference/cache/cache#removeAll(String)) | `void` | Removes a set of entries from the cache. |\n\n[CacheService](/apps-script/reference/cache/cache-service)\n----------------------------------------------------------\n\n### Methods\n\n| Method | Return type | Brief description |\n|-------------------------------------------------------------------------------------|---------------------------------------------|--------------------------------------------------------------------|\n| [getDocumentCache()](/apps-script/reference/cache/cache-service#getDocumentCache()) | [Cache](/apps-script/reference/cache/cache) | Gets the cache instance scoped to the current document and script. |\n| [getScriptCache()](/apps-script/reference/cache/cache-service#getScriptCache()) | [Cache](/apps-script/reference/cache/cache) | Gets the cache instance scoped to the script. |\n| [getUserCache()](/apps-script/reference/cache/cache-service#getUserCache()) | [Cache](/apps-script/reference/cache/cache) | Gets the cache instance scoped to the current user and script. |"]]