Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(appsync): add ApiCache L2 construct and addCache method #31174

Closed
wants to merge 9 commits into from
Prev Previous commit
Next Next commit
update README
TonySherman committed Aug 22, 2024
commit 6e59e149b2797819e732806ca2bc0d65c27a5c95
29 changes: 29 additions & 0 deletions packages/aws-cdk-lib/aws-appsync/README.md
Original file line number Diff line number Diff line change
@@ -909,3 +909,32 @@ rule.addTarget(new targets.AppSync(api, {
}),
}));
```

## Caching

You can create a cache for an API using the `apiId` from an existing graphQL API or add a cache
to an existing graphQL API resource.

```ts
const api = new appsync.GraphqlApi(this, 'api', {
name: 'api',
definition: appsync.Definition.fromFile(path.join(__dirname, 'appsync.schema.graphql')),
environmentVariables: {
EnvKey1: 'non-empty-1',
},
});

const cache = new appsync.ApiCache(stack, 'ApiCache', {
apiId: api.apiId,
apiCachingBehavior: appsync.CacheBehavior.FULL_REQUEST_CACHING,
type: appsync.CacheType.LARGE,
ttl: 60,
});

// or with the addCache method:
api.addCache('ApiCache', {
apiCachingBehavior: appsync.CacheBehavior.PER_RESOLVER_CACHING,
type: appsync.CacheType.LARGE,
ttl: 360,
});
```
Loading