Skip to content

sharedTags and sharedTagsTtl in Redis never expire and grow indefinitely if revalidate is not called explicitly #83

@sad-scope

Description

@sad-scope

Hello!

When using @fortedigital/nextjs-cache-handler/redis-strings, Redis not only stores the actual cache entries but also creates sharedTags and sharedTagsTtl keys.
Both sharedTags and sharedTagsTtl are created with TTL = -1, meaning they never expire.

Entries inside these structures are never cleaned up and keep accumulating over time.
This leads to unbounded growth in Redis usage, which can reach gigabytes and significantly impact performance and storage costs.

The cache lifetime is 300 seconds. And redis clears the keys when ttl ends.

Steps to reproduce:
Configure caching with @fortedigital/nextjs-cache-handler/redis-strings.
Request multiple pages so they are cached.
Inspect Redis:
sharedTags and sharedTagsTtl keys exist,
Both have TTL = -1,
Their size keeps growing with more cached entries.
Expected behavior:
sharedTags and sharedTagsTtl should either:
Expire together with the cache entries they reference, or
Be periodically cleaned up to prevent unbounded growth.
Actual behavior:
sharedTags and sharedTagsTtl never expire.
They continuously accumulate data and can consume large amounts of memory.
And the records inside these structures (sharedTags and sharedTagsTtl) are not cleared

Image Image

Environment:
Package: @fortedigital/nextjs-cache-handler: 2.0.3
Redis version: 5.8.2
Node.js version: 22.19.0
Next.js version: 15.3.4

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions