aws / aws-appsync-community

The AWS AppSync community
https://aws.amazon.com/appsync
Apache License 2.0
506 stars 32 forks source link

Evicting multiple items from cache using key prefix, is this possible? #331

Closed jbschooley closed 11 months ago

jbschooley commented 1 year ago

One of my resolvers has caching keys context.source.id and context.arguments (arguments only optionally contains nextToken). When the object is updated, I would like to evict all items where the key begins with context.source.id no matter what their arguments are. Is there any way to do this?

I've tried evicting keys with only context.source.id (doesn't work) and with context.arguments set to * (also doesn't work). Documentation does not cover this at all. This is a pretty big deal as caching removes so much load from the database, but users who make updates need to be able to see those updates immediately.

ndejaco2 commented 1 year ago

This is not possible today. We do not support regex when performing eviction. An operation like this would impact performance when scanning cache keys to determine what should be deleted. These scans can impact performance for all traffic to the cache. You can use the https://docs.aws.amazon.com/appsync/latest/APIReference/API_FlushApiCache.html API to flush the cache completely.