diff --git a/ttl/ttl.go b/ttl/ttl.go index 0be7080..3a4ae10 100644 --- a/ttl/ttl.go +++ b/ttl/ttl.go @@ -152,19 +152,13 @@ func (shard *shard) cleanup(ctx context.Context, ttl *TTL) { case <-ctx.Done(): return case <-ticker.C: - var expiredKeys []string - shard.mutex.Lock() for k, v := range shard.data { if v.expirationTime.Before(time.Now()) { - expiredKeys = append(expiredKeys, k) + delete(shard.data, k) } } - for _, k := range expiredKeys { - delete(shard.data, k) - } - if len(shard.data) == 0 { shard.mutex.Unlock()