Fix: cache cleanup panic

This commit is contained in:
yaling888 2022-05-25 02:00:24 +08:00
parent 6ad2cde909
commit 22449da5d3

View File

@ -61,7 +61,7 @@ func (c *cache[K, V]) GetWithExpire(key K) (payload V, expired time.Time) {
func (c *cache[K, V]) cleanup() {
c.mapping.Range(func(k, v any) bool {
key := k.(string)
key := k
elm := v.(*element[V])
if time.Since(elm.Expired) > 0 {
c.mapping.Delete(key)