Fix time-based cache expiration practically never working.

config.MaxAge is now a nanosecond value, and multiplying it by
time.Second (number of nanoseconds in a second) will make it too large
for the cache expiry algorithm to have any effect.
This commit is contained in:
miyuko
2025-10-05 15:05:12 +01:00
parent 0eede0792d
commit a85905bd31

View File

@@ -121,7 +121,7 @@ func makeCacheOptions[K comparable, V any](
options.Weigher = weigher
}
if config.MaxAge != 0 {
options.ExpiryCalculator = otter.ExpiryWriting[K, V](time.Duration(config.MaxAge) * time.Second)
options.ExpiryCalculator = otter.ExpiryWriting[K, V](time.Duration(config.MaxAge))
}
return options
}