This command is highly NOT recommended for production setup because it can block the redis server if we have a large amount of keys stored in cache. As a matter of fact Upstash is ignoring KEYS commands when redis sizes > 100k keys.
I experienced myself a degraded Medusa performance with query sometimes hitting 10/15s response time due to this issue.
Below you can find articles from Upstash and Redis advising to use the SCAN command instead that will split the search in several commands:
Bug report
Describe the bug
In cache-redis the invalidate function is using KEYS command.
const keys = await this.redis.keys(this.getCacheKey(key))
This command is highly NOT recommended for production setup because it can block the redis server if we have a large amount of keys stored in cache. As a matter of fact Upstash is ignoring KEYS commands when redis sizes > 100k keys.
I experienced myself a degraded Medusa performance with query sometimes hitting 10/15s response time due to this issue.
Below you can find articles from Upstash and Redis advising to use the SCAN command instead that will split the search in several commands:
Upstash article and Redis article