Cleanup cleans the expired reader from cache.
()
| 134 | |
| 135 | // Cleanup cleans the expired reader from cache. |
| 136 | func (c *storeCache) Cleanup() { |
| 137 | c.mutex.Lock() |
| 138 | defer c.mutex.Unlock() |
| 139 | |
| 140 | ttl := c.ttl.Milliseconds() |
| 141 | c.cache.Walk(func(entry *cacheEntry) bool { |
| 142 | if entry.ref.Load() == 0 && timeutil.Now()-entry.last > ttl { |
| 143 | c.evict(entry) |
| 144 | metrics.TableCacheStatistics.Evict.Incr() |
| 145 | return true |
| 146 | } |
| 147 | return false |
| 148 | }) |
| 149 | } |
| 150 | |
| 151 | // Close closes reader resource and cleans cache data. |
| 152 | func (c *storeCache) Close() error { |