revalidateTag() is creating multiple indexes
Brief Description of the Bug The revalidateTag() of redis-stack handler is creating multiple Redis indexes when our app is escalated.
Severity Minor
Frequency of Occurrence Always
Steps to Reproduce Deploy many replicas of an app that uses redis-stack cache handler
Expected vs. Actual Behavior The first call to revalidateTag() function of redis-stack handler is trying to create an index with name based on a random string.
The problem here is that if we have many replicas of our app, we will be creating the same index many times.
Also, when creating the index on the first call, I have detected that many times that first call don't purge the cache. Wouldn't it be better to define the index at another time?
Screenshots/Logs 127.0.0.1:6379> FT._LIST
- idx:tags-c3eacfce78f22c83cf513188bdc1fbf8299c974e93b750e9fa2f74658485c874
- idx:tags-fb3937612f4a80a9b677ecb02c906c7e7a33c7efd09fed170eab482a7efb5d91
- idx:tags-d2ad2c38698b2f4f95b6a272574b73be80d70e97b39040a8d763a3d0dae8a61f
- idx:tags-7589c9e50728dc75ee45dab9c997969f802c6f06453898dc46ec8f056f4eef38
- idx:tags-3412e4810ca9b3edf743f671e89e1f0d4fd945a354825f8c5691c7e0ef823809
- idx:tags-7f832efcbb3bd742bb51d9652e9f21650174a5b0d3dfedd8ad32399d1b09b21d
Environment:
- OS: MacOS
- Node.js version: 22.11.0
-
@neshca/cache-handlerversion: 1.8.1 -
nextversion: 15.0.2
+1
We have the same issue, having multiple indexes for the same tag significantly increases memory usage on our redis server. Since we are running multiple instances (Up to 10 or more replicas) this means the memory usage is often more than 10x of what would be required. Having multiple indices also removes any benefit of having a shared cache.
Recommended solution: instead of using random string, either use tag name for the index, or create a hash based on the tag.