You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs-js/features/connectivity/destination-cache-isolation.mdx
+13-12Lines changed: 13 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,22 +22,23 @@ To reduce the number of calls to fetch destinations, the SAP Cloud SDK provides
22
22
This guide explains how destinations are cached and shows options for destination cache configuration.
23
23
The general destination lookup is described in [this guide](./destination.mdx).
24
24
25
-
All options discussed in the following are part of the [`DestinationFetchOptions`](pathname:///api/v3/interfaces/sap_cloud_sdk_connectivity.DestinationFetchOptions.html).
25
+
All options discussed in the following are part of the [`DestinationFetchOptions`](pathname:///api/v4/interfaces/sap_cloud_sdk_connectivity.DestinationFetchOptions.html).
26
26
You use those options when:
27
27
28
28
- executing requests through a generated client using `execute()`
29
-
- executing generic HTTP requests using [`executeHttpRequest()`](pathname:///api/v3/functions/sap_cloud_sdk_http_client.executeHttpRequest.html)
30
-
- retrieving destinations using [`getDestination()`](pathname:///api/v3/functions/sap_cloud_sdk_connectivity.getDestination.html)
29
+
- executing generic HTTP requests using [`executeHttpRequest()`](pathname:///api/v4/functions/sap_cloud_sdk_http_client.executeHttpRequest.html)
30
+
- retrieving destinations using [`getDestination()`](pathname:///api/v4/functions/sap_cloud_sdk_connectivity.getDestination.html)
31
+
- retrieving all destinations using[`getAllDestinationsFromDestinationService()`](pathname:///api/v4/functions/sap_cloud_sdk_connectivity.getAllDestinationsFromDestinationService.html)
31
32
32
33
The following examples will use `execute()` for brevity, but could be replaced by all of the above.
33
34
34
35
## Destination Cache
35
36
36
-
By default, destination caching is disabled.
37
-
Enable it by setting the [`useCache`](pathname:///api/v3/interfaces/sap_cloud_sdk_connectivity.DestinationFetchOptions.html#useCache) option to `true`:
37
+
By default, destination caching is enabled.
38
+
You can disable it by setting the [`useCache`](pathname:///api/v4/interfaces/sap_cloud_sdk_connectivity.DestinationFetchOptions.html#useCache) option to `false`:
The destination cache holds destinations that potentially require HTTP requests, i.e.:
@@ -86,7 +87,7 @@ Assume you have a multi-tenant scenario, where you pass a JWT to obtain the dest
86
87
The JWT contains a `user_id` but the authentication type of the destination is user-independent.
87
88
The default isolation strategy for this case is `tenant-user`, although `tenant` would suffice.
88
89
89
-
For such cases, you can manually enforce weaker isolation by passing the [`isolationStrategy`](pathname:///api/v3/interfaces/sap_cloud_sdk_connectivity.DestinationFetchOptions.html#isolationStrategy) option:
90
+
For such cases, you can manually enforce weaker isolation by passing the [`isolationStrategy`](pathname:///api/v4/interfaces/sap_cloud_sdk_connectivity.DestinationFetchOptions.html#isolationStrategy) option:
90
91
91
92
```ts
92
93
.execute({
@@ -104,9 +105,9 @@ An erroneous configuration can have severe consequences like privilege escalatio
104
105
105
106
## Custom Destination Cache
106
107
107
-
When caching is enabled, destinations are cached in-memory.
108
+
By default, destinations are cached in-memory.
108
109
If you need more control over the destination cache, e.g. to use a persistent or distributed cache, you can create a custom destination cache.
109
-
For this, implement the [`DestinationCacheInterface`](pathname:///api/v3/interfaces/sap_cloud_sdk_connectivity.DestinationCacheInterface.html):
110
+
For this, implement the [`DestinationCacheInterface`](pathname:///api/v4/interfaces/sap_cloud_sdk_connectivity.DestinationCacheInterface.html):
Note that each item in the cache is represented using the [`CacheEntry<T>`](pathname:///api/v3/interfaces/sap_cloud_sdk_connectivity.CacheEntry.html) type, which defines two properties:
137
+
Note that each item in the cache is represented using the [`CacheEntry<T>`](pathname:///api/v4/interfaces/sap_cloud_sdk_connectivity.CacheEntry.html) type, which defines two properties:
137
138
138
139
-`entry` - The item, i.e. destination, you want to cache.
139
140
-`expires` - The expiration time of the entry in milliseconds.
@@ -166,7 +167,7 @@ const customCache = {
166
167
};
167
168
```
168
169
169
-
To use your custom cache, pass your implementation to the global [`setDestinationCache()`](pathname:///api/v3/functions/sap_cloud_sdk_connectivity.setDestinationCache.html) function before fetching destinations for the first time.
170
+
To use your custom cache, pass your implementation to the global [`setDestinationCache()`](pathname:///api/v4/functions/sap_cloud_sdk_connectivity.setDestinationCache.html) function before fetching destinations for the first time.
170
171
All subsequent calls to fetch destinations will use the custom cache.
When [registering destinations](./destination.mdx#register-destination) using the [`registerDestination()`](pathname:///api/v3/functions/sap_cloud_sdk_connectivity.registerDestination.html) function, destinations are stored in a separate cache.
183
+
When [registering destinations](./destination.mdx#register-destination) using the [`registerDestination()`](pathname:///api/v4/functions/sap_cloud_sdk_connectivity.registerDestination.html) function, destinations are stored in a separate cache.
183
184
This cache is always enabled and behaves similarly to the destination cache discussed above.
184
185
It uses the same JWT-dependent defaults for the [isolation strategy](#isolation-strategy) as the destination cache.
185
186
To change the isolation strategy pass the `isolationStrategy` option to the function.
This configures HTTPS requests to automatically check for the `CF_INSTANCE_CERT` and `CF_INSTANCE_KEY` environment variables and read the certificate and key.
170
170
171
-
The caching of mTLS certificates is disabled by default, but can be enabled by adding the `useCache` option:
171
+
The caching of mTLS certificates is disabled by default, but can be enabled by adding the `useMtlsCache` option:
172
172
173
-
```
173
+
````
174
174
const options: RegisterDestinationOptions = {
175
175
inferMtls: true,
176
-
useCache: true
176
+
useMtlsCache: true
177
177
};
178
-
```
178
+
179
179
180
180
Certificates are then cached for the entire validity time of the certificate.
181
181
Since in Cloud Foundry each deployment has their own mTLS certificate, the cache is shared among all tenants of a deployment.
@@ -219,7 +219,7 @@ Additionally, we provide a function to transform service bindings into OAuth2Cli
219
219
]
220
220
}
221
221
}
222
-
```
222
+
````
223
223
224
224
If the service URL is not specified in the `url` property, it can alternatively be provided as part of the `options` parameter.
225
225
@@ -492,7 +492,7 @@ A few of the options were already listed above, but this section gives a compreh
492
492
-`cacheVerificationKeys`: Switches on caching for the verification certificates for the JWT.
493
493
The default value is `true`.
494
494
-`useCache`: Switches on caching for destinations received from the destination service.
495
-
The default value is `false`.
495
+
The default value is `true`. You can set it to `false` to disable caching.
496
496
-`isolationStrategy`: Specifies how the destination cache is scoped.
497
497
The value is automatically set but [under certain conditions](./destination-cache-isolation.mdx) you may want to optimize it.
498
498
-`retry`: Switches on three retries for the request to the destination service.
0 commit comments