Files
Alfred LandrumandGitHub 27aee0375b support background entry removal for workflow cache (#7902)
## What changed?
This adds support to the lru cache to actively expire entries older than
the TTL, by spawning a background goroutine that periodically deletes
old entries. A dynamic config, off by default, is added that can enable
this feature for the workflow cache.

## Why?
This can reduce the memory usage, and associated Go GC resource usage,
for workflow entries that won't be utilized since they are past their
TTL.

## How did you test it?
- [x] built
- [x] run locally and tested manually
- [x] covered by existing tests
- [x] added new unit test(s)
- [ ] added new functional test(s)

Also running this in test setups to verify expected memory reduction.

## Potential risks
2025-07-25 10:04:29 -07:00

26 lines
333 B
Go

package cache
import (
"context"
"go.uber.org/fx"
)
var Module = fx.Options(
fx.Provide(NewHostLevelCache),
fx.Invoke(func(
lc fx.Lifecycle,
cache Cache,
) {
lc.Append(fx.Hook{
OnStop: func(_ context.Context) error {
ci, ok := cache.(*cacheImpl)
if ok {
ci.stop()
}
return nil
},
})
}),
)