Values returns a slice of the values in the cache, from oldest to newest. Expired entries are filtered out.
()
| 251 | // Values returns a slice of the values in the cache, from oldest to newest. |
| 252 | // Expired entries are filtered out. |
| 253 | func (c *LRU[K, V]) Values() []V { |
| 254 | c.mu.RLock() |
| 255 | defer c.mu.RUnlock() |
| 256 | values := make([]V, 0, len(c.items)) |
| 257 | now := time.Now() |
| 258 | for ent := c.evictList.Back(); ent != nil; ent = ent.PrevEntry() { |
| 259 | if now.After(ent.ExpiresAt) { |
| 260 | continue |
| 261 | } |
| 262 | values = append(values, ent.Value) |
| 263 | } |
| 264 | return values |
| 265 | } |
| 266 | |
| 267 | // Len returns the number of items in the cache. |
| 268 | func (c *LRU[K, V]) Len() int { |