Skip to content

Commit b89c150

Browse files
authored
chore: (v4) Document default caching behaviour during destination retrieval (#2011)
1 parent 6ccc9d6 commit b89c150

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

docs-js/features/connectivity/destination-cache-isolation.mdx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,23 @@ To reduce the number of calls to fetch destinations, the SAP Cloud SDK provides
2222
This guide explains how destinations are cached and shows options for destination cache configuration.
2323
The general destination lookup is described in [this guide](./destination.mdx).
2424

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).
2626
You use those options when:
2727

2828
- 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)
3132

3233
The following examples will use `execute()` for brevity, but could be replaced by all of the above.
3334

3435
## Destination Cache
3536

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`:
3839

3940
```ts
40-
.execute({ destinationName: 'DESTINATION', jwt: 'JWT', useCache: true })
41+
.execute({ destinationName: 'DESTINATION', jwt: 'JWT', useCache: false })
4142
```
4243

4344
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
8687
The JWT contains a `user_id` but the authentication type of the destination is user-independent.
8788
The default isolation strategy for this case is `tenant-user`, although `tenant` would suffice.
8889

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:
9091

9192
```ts
9293
.execute({
@@ -104,9 +105,9 @@ An erroneous configuration can have severe consequences like privilege escalatio
104105

105106
## Custom Destination Cache
106107

107-
When caching is enabled, destinations are cached in-memory.
108+
By default, destinations are cached in-memory.
108109
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):
110111

111112
```ts
112113
export interface DestinationCacheInterface {
@@ -133,7 +134,7 @@ export interface DestinationCacheInterface {
133134
}
134135
```
135136

136-
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:
137138

138139
- `entry` - The item, i.e. destination, you want to cache.
139140
- `expires` - The expiration time of the entry in milliseconds.
@@ -166,7 +167,7 @@ const customCache = {
166167
};
167168
```
168169

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.
170171
All subsequent calls to fetch destinations will use the custom cache.
171172

172173
```ts
@@ -179,7 +180,7 @@ setDestinationCache(customCache);
179180

180181
## Registered Destination Cache
181182

182-
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.
183184
This cache is always enabled and behaves similarly to the destination cache discussed above.
184185
It uses the same JWT-dependent defaults for the [isolation strategy](#isolation-strategy) as the destination cache.
185186
To change the isolation strategy pass the `isolationStrategy` option to the function.

docs-js/features/connectivity/destination.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,14 @@ const options: RegisterDestinationOptions = {
168168

169169
This configures HTTPS requests to automatically check for the `CF_INSTANCE_CERT` and `CF_INSTANCE_KEY` environment variables and read the certificate and key.
170170

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:
172172

173-
```
173+
````
174174
const options: RegisterDestinationOptions = {
175175
inferMtls: true,
176-
useCache: true
176+
useMtlsCache: true
177177
};
178-
```
178+
179179
180180
Certificates are then cached for the entire validity time of the certificate.
181181
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
219219
]
220220
}
221221
}
222-
```
222+
````
223223

224224
If the service URL is not specified in the `url` property, it can alternatively be provided as part of the `options` parameter.
225225

@@ -492,7 +492,7 @@ A few of the options were already listed above, but this section gives a compreh
492492
- `cacheVerificationKeys`: Switches on caching for the verification certificates for the JWT.
493493
The default value is `true`.
494494
- `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.
496496
- `isolationStrategy`: Specifies how the destination cache is scoped.
497497
The value is automatically set but [under certain conditions](./destination-cache-isolation.mdx) you may want to optimize it.
498498
- `retry`: Switches on three retries for the request to the destination service.

0 commit comments

Comments
 (0)