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

Clearing PER_RESOLVER_CACHE using wildcards #370

Open
antennix opened this issue Aug 23, 2024 · 0 comments
Open

Clearing PER_RESOLVER_CACHE using wildcards #370

antennix opened this issue Aug 23, 2024 · 0 comments

Comments

@antennix
Copy link

■ Overview
I'm trying to retrieve a list of regional information stored in DynamoDB using Amplify Gen2's data feature in TypeScript.
(I understand this isn't an Amplify community.)

project/amplify/data/resource.ts
const schema = a.schema({ Area: a.model({ area_name: a.string() }) })

This code retrieves the list of areas from the browser, but because the list is very large, it can't be retrieved in a single Query.
Therefore, I use loop processing with nextToken, repeating the process until there's no nextPageToken in the API response.

app/page.tsx
let areaList;
do {
    areaList = await Area.list({ nextToken: nextPageToken });
} while(areaList.nextPageToken);

From here on, this is a general discussion:
For this listArea Query, I set $context.args as the cache key from the management console and set a TTL.
If 10 loops occur to retrieve this area list, I think PER_RESOLVER_CACHE will maintain about 10 caches using nextToken as the cache key.

■ Question
If a specific area record is updated, I need to flush all caches of listArea in the resolver.
Can I delete all listArea caches by using evictFromApiCache and specifying nextToken with a wildcard?
Or is there an easier way?

Since I can't solve this problem, I'm considering creating Lambda resolvers that retrieve all regional information at once and setting up caching for this resolver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant