با مجموعهها، منظم بمانید ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
سرویس کش
Cache Service به شما امکان می دهد برای ذخیره کوتاه مدت داده ها به یک کش دسترسی داشته باشید.
این کلاس به شما امکان می دهد یک نمونه کش خاص را دریافت کنید. کش های عمومی برای چیزهایی هستند که بستگی به این ندارند که چه کاربری به اسکریپت شما دسترسی دارد. حافظه پنهان خصوصی برای چیزهایی هستند که مختص کاربر هستند، مانند تنظیمات یا فعالیت اخیر.
داده هایی که در حافظه پنهان می نویسید تا زمان انقضا آن تضمین نمی شود. شما باید آماده باشید که از همه خواندهها، null دریافت کنید.
نمونه حافظه پنهان را به سند و اسکریپت فعلی میرساند. حافظه پنهان سند مخصوص سند فعلی است که حاوی اسکریپت است. از اینها برای ذخیره اطلاعات اسکریپت که مخصوص سند فعلی است استفاده کنید. اگر این روش خارج از زمینه یک سند حاوی فراخوانی شود (مانند یک اسکریپت مستقل یا برنامه وب)، این روش null را برمیگرداند.
// Gets a cache that is specific to the current document containing the scriptconstcache=CacheService.getDocumentCache();
بازگشت
Cache - یک نمونه حافظه پنهان سند، یا اگر سندی حاوی آن وجود نداشته باشد، null
get Script Cache()
نمونه حافظه پنهان را با محدوده اسکریپت دریافت می کند. حافظه پنهان اسکریپت برای همه کاربران اسکریپت مشترک است. از اینها برای ذخیره اطلاعاتی که مختص کاربر فعلی نیست استفاده کنید.
// Gets a cache that is common to all users of the scriptconstcache=CacheService.getScriptCache();
نمونه کش را به کاربر فعلی و اسکریپت میرساند. حافظه پنهان کاربر مختص کاربر فعلی اسکریپت است. از اینها برای ذخیره اطلاعات اسکریپت که مختص کاربر فعلی است استفاده کنید.
// Gets a cache that is specific to the current user of the scriptconstcache=CacheService.getUserCache();
تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003e\u003ccode\u003eCacheService\u003c/code\u003e provides short-term storage for script data, offering document, script, and user-specific scopes.\u003c/p\u003e\n"],["\u003cp\u003eData stored using \u003ccode\u003eCacheService\u003c/code\u003e is not guaranteed to persist and may return \u003ccode\u003enull\u003c/code\u003e when retrieved.\u003c/p\u003e\n"],["\u003cp\u003eThree cache instances are available: \u003ccode\u003egetDocumentCache()\u003c/code\u003e for document-specific data, \u003ccode\u003egetScriptCache()\u003c/code\u003e for script-wide data, and \u003ccode\u003egetUserCache()\u003c/code\u003e for user-specific data.\u003c/p\u003e\n"],["\u003cp\u003eWhen using \u003ccode\u003egetDocumentCache()\u003c/code\u003e, it returns \u003ccode\u003enull\u003c/code\u003e if called outside a document context (standalone script or web app).\u003c/p\u003e\n"]]],[],null,["CacheService\n\nCacheService allows you to access a cache for short term storage of data.\n\nThis class lets you get a specific cache instance. Public caches are for things that are not\ndependent on which user is accessing your script. Private caches are for things which are\nuser-specific, like settings or recent activity.\n\nThe data you write to the cache is not guaranteed to persist until its expiration time. You\nmust be prepared to get back `null` from all reads. \n\nMethods\n\n| Method | Return type | Brief description |\n|-------------------------------------------|---------------------------------------------|--------------------------------------------------------------------|\n| [getDocumentCache()](#getDocumentCache()) | [Cache](/apps-script/reference/cache/cache) | Gets the cache instance scoped to the current document and script. |\n| [getScriptCache()](#getScriptCache()) | [Cache](/apps-script/reference/cache/cache) | Gets the cache instance scoped to the script. |\n| [getUserCache()](#getUserCache()) | [Cache](/apps-script/reference/cache/cache) | Gets the cache instance scoped to the current user and script. |\n\nDetailed documentation \n\n`get``Document``Cache()` \nGets the cache instance scoped to the current document and script. Document caches are specific\nto the current document which contains the script. Use these to store script information that\nis specific to the current document. If this method is called outside of the context of a\ncontaining document (such as from a standalone script or web app), this method returns `null`.\n\n```javascript\n// Gets a cache that is specific to the current document containing the script\nconst cache = CacheService.getDocumentCache();\n```\n\nReturn\n\n\n[Cache](/apps-script/reference/cache/cache) --- a document cache instance, or `null` if there is no containing document\n\n*** ** * ** ***\n\n`get``Script``Cache()` \nGets the cache instance scoped to the script. Script caches are common to all users of the\nscript. Use these to store information that is not specific to the current user.\n\n```javascript\n// Gets a cache that is common to all users of the script\nconst cache = CacheService.getScriptCache();\n```\n\nReturn\n\n\n[Cache](/apps-script/reference/cache/cache) --- a script cache instance\n\n*** ** * ** ***\n\n`get``User``Cache()` \nGets the cache instance scoped to the current user and script. User caches are specific to the\ncurrent user of the script. Use these to store script information that is specific to the\ncurrent user.\n\n```javascript\n// Gets a cache that is specific to the current user of the script\nconst cache = CacheService.getUserCache();\n```\n\nReturn\n\n\n[Cache](/apps-script/reference/cache/cache) --- a user cache instance"]]