FifoCache is a simple string -> interface{} cache which uses a fifo slide to manage evictions. O(1) inserts and updates, O(1) gets.
| 65 | // FifoCache is a simple string -> interface{} cache which uses a fifo slide to |
| 66 | // manage evictions. O(1) inserts and updates, O(1) gets. |
| 67 | type FifoCache struct { |
| 68 | lock sync.RWMutex |
| 69 | maxSizeItems int |
| 70 | maxSizeBytes uint64 |
| 71 | currSizeBytes uint64 |
| 72 | validity time.Duration |
| 73 | |
| 74 | entries map[string]*list.Element |
| 75 | lru *list.List |
| 76 | |
| 77 | entriesAdded prometheus.Counter |
| 78 | entriesAddedNew prometheus.Counter |
| 79 | entriesEvicted prometheus.Counter |
| 80 | entriesCurrent prometheus.Gauge |
| 81 | totalGets prometheus.Counter |
| 82 | totalMisses prometheus.Counter |
| 83 | staleGets prometheus.Counter |
| 84 | memoryBytes prometheus.Gauge |
| 85 | } |
| 86 | |
| 87 | type cacheEntry struct { |
| 88 | updated time.Time |
nothing calls this directly
no outgoing calls
no test coverage detected