()
| 218 | } |
| 219 | |
| 220 | func (c *LRU[K, V]) KeyValues() map[K]V { |
| 221 | c.mu.RLock() |
| 222 | defer c.mu.RUnlock() |
| 223 | maps := make(map[K]V) |
| 224 | now := time.Now() |
| 225 | for ent := c.evictList.Back(); ent != nil; ent = ent.PrevEntry() { |
| 226 | if now.After(ent.ExpiresAt) { |
| 227 | continue |
| 228 | } |
| 229 | maps[ent.Key] = ent.Value |
| 230 | // keys = append(keys, ent.Key) |
| 231 | } |
| 232 | return maps |
| 233 | } |
| 234 | |
| 235 | // Keys returns a slice of the keys in the cache, from oldest to newest. |
| 236 | // Expired entries are filtered out. |