[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-03。"],[[["\u003cp\u003eApigee offers several persistence features, including caches, key value maps (KVMs), and property sets, to store and manage data used by API proxies.\u003c/p\u003e\n"],["\u003cp\u003eCaches are used for general-purpose caching to persist objects across sessions, reduce latency, and cache backend responses for data that is updated periodically, with management of expiry times and keys through cache policies.\u003c/p\u003e\n"],["\u003cp\u003eKey value maps (KVMs) provide a long-term data store for arbitrary key/value pairs with different scopes, ideal for data like IP-to-country mappings or OAuth token expiration times.\u003c/p\u003e\n"],["\u003cp\u003eProperty sets are used to store non-expiring configuration data that can vary by environment, accessible via flow variables within API proxies.\u003c/p\u003e\n"],["\u003cp\u003eApigee hybrid users can utilize Kubernetes secrets to store and manage sensitive data, with this data being accessible in API proxy flow variables.\u003c/p\u003e\n"]]],[],null,["# Caching and persistence overview\n\n*This page\napplies to **Apigee** and **Apigee hybrid**.*\n\n\n*View [Apigee Edge](https://docs.apigee.com/api-platform/get-started/what-apigee-edge) documentation.*\n\nApigee persistence features include caches, key value maps, and\nproperty sets. If you are using Apigee hybrid, you can use Kubernetes secrets\nto persist sensitive data.\n\nCaching\n-------\n\n\nEnvironment-scoped cache resources are created dynamically when a cache policy executes within an API proxy flow.\nCache policies include the [PopulateCache policy](/apigee/docs/api-platform/reference/policies/populate-cache-policy),\n[LookupCache policy](/apigee/docs/api-platform/reference/policies/lookup-cache-policy), [InvalidateCache policy](/apigee/docs/api-platform/reference/policies/invalidate-cache-policy), and\n[ResponseCache policy](/apigee/docs/api-platform/reference/policies/response-cache-policy).\n\n\nA cached item stays in memory (L1) for one second. You cannot change this configuration.\nAfter one second, the cached object is placed in a database (L2) where it is available until\nthe cache expires. For details, see [In-memory persistent cache levels](/apigee/docs/api-platform/cache/cache-internals#inmemoryandpersistentcachelevels).\nYou manage cache details, such as expiry time, through\nconfiguration of a cache policy. An Apigee API is provided that allows you to [list and\ndelete](/apigee/docs/reference/apis/apigee/rest#rest-resource:-v1.organizations.environments.caches) cache resources.\n\nWhen using cache policies, you ensure the uniqueness of cached value keys by\nconfiguring [cache keys](/apigee/docs/api-platform/reference/policies/working-cachekeys). A cache key, along with other values you can\nconfigure, gives you a reliable way to get out the same data that you put in. Cache size\nand availability is subject to certain [limits](/apigee/docs/api-platform/reference/limits#persistence:-cache,-kvm,-property-sets).\n\nYou might want to use a cache to:\n\n- **Reduce latency and traffic.** Requests are satisfied in a shorter time and with reused representations.\n- **Persist data across transactions.** You can store session data for reuse across HTTP transactions.\n- **Support security.** Scope access to cache entries so they can be accessed only in a particular environment or by a specific API proxy.\n\n### Backend response caching\n\nYou can cache the response of a backend resource with the\n[`ResponseCache` policy](/apigee/docs/api-platform/reference/policies/response-cache-policy).\n\nThis is especially helpful when backend data is updated only periodically. The `ResponseCache`\npolicy can reduce calls to backend data sources.\n\nThrough the `ResponseCache` policy, you can also have Apigee look at certain HTTP response caching\nheaders and take actions according to header directives. For example, on responses from backend\ntargets, Apigee supports the `Cache-Control` header. This header can be used to control\nthe maximum age of a cached response, among other things. For more information, see\n[Support for HTTP response headers](/apigee/docs/api-platform/cache/http-response-caching).\n\n### Short-term general purpose caching\n\nUsing policies for general purpose caching, you can persist any objects your proxy requires\nacross multiple request/response sessions.\n\nWith the [`PopulateCache`\npolicy](/apigee/docs/api-platform/reference/policies/populate-cache-policy), [`LookupCache`\npolicy](/apigee/docs/api-platform/reference/policies/lookup-cache-policy), and [`InvalidateCache` policy](/apigee/docs/api-platform/reference/policies/invalidate-cache-policy),\nyou can populate, retrieve, and flush cached data at runtime.\n\nFor example, you might temporarily store:\n\n- Session IDs for session management.\n- Credentials for outbound calls (such as API keys or OAuth access tokens).\n- Response content that must be paginated for apps.\n\nAt runtime, your cache policies copy values between proxy variables and the configured cache\nyou specify. When a value is placed in the cache, it is copied from the variable you specify to\nthe cache. When it is retrieved from the cache, it is copied into the variable for use by your\nproxy.\n\nFor an example with code, see\n[Example: General purpose caching](/apigee/docs/api-platform/cache/optimize-performance-using-cache).\n\n### Managing cache with the Apigee API\n\nYou can list and delete caches using the\n[caches API](/apigee/docs/reference/apis/apigee/rest/v1/organizations.environments.caches).\n\nLong-term persistence with key value maps (KVMs)\n------------------------------------------------\n\nTo indefinitely store structured data either encrypted or unencrypted, you can create and\npopulate key value maps (KVMs) that contain arbitrary key/value pairs. For example, you might\nstore:\n\n- A map correlating IP addresses to country codes.\n- A list of IP addresses that are allowed/denied access.\n- A map correlating long URLs to shortened URLs.\n- Environment-specific data, such as quota counts and OAuth token expiration times.\n\nKVMs can have one of three scopes: organization, environment, apiproxy. For example, if\nkey/value pairs are to be used for all APIs in an organization, create a KVM at the organization\nscope; or if only a specific API proxy should have access to keys/values, create the KVM at the\napiproxy scope. For more information, see [Working with key value maps](/apigee/docs/api-platform/cache/key-value-maps).\n\nProperty sets\n-------------\n\nA *property set* is a custom collection of key/value pairs\nthat store data. API proxies can retrieve this data when they execute.\n\nTypically, you use property sets to store non-expiring data that shouldn't be\nhard-coded in your API proxy logic, such as configuration data. You can access property set data anywhere in a proxy where you\ncan access [flow variables](/apigee/docs/api-platform/fundamentals/introduction-flow-variables).\n\nA common use case for property sets is to provide values that are\nassociated with one environment or another. For example, you can\ncreate an environment-scoped property set with configuration values that are\nspecific to proxies running in your test environment, and another\nset for your production environment.\n\n\nFor more information, see [Using property sets](/apigee/docs/api-platform/cache/property-sets).\n\nKubernetes secrets\n------------------\n\n\n(Apigee hybrid only) If you are already using Kubernetes for secret management in a custom vault for sensitive\ndata, you might want to consider using [Kubernetes Secrets](https://kubernetes.io/docs/concepts/configuration/secret/).\nJust like with KVM data, you can access the Kubernetes secret data in API proxy flow variables.\nFor more information, see [Storing data in a Kubernetes secret](/apigee/docs/hybrid/v1.3/k8s-secrets)."]]