mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 16:30:55 +01:00
lib/mergeset: properly update lastAccesstime
in indexBlockCache entries
This is a follow-up for 6665f10e7b
This commit is contained in:
parent
170c1c3a4e
commit
cb2a2f281f
@ -172,7 +172,7 @@ type indexBlockCache struct {
|
||||
requests uint64
|
||||
misses uint64
|
||||
|
||||
m map[uint64]indexBlockCacheEntry
|
||||
m map[uint64]*indexBlockCacheEntry
|
||||
mu sync.RWMutex
|
||||
|
||||
cleanerStopCh chan struct{}
|
||||
@ -190,7 +190,7 @@ type indexBlockCacheEntry struct {
|
||||
|
||||
func newIndexBlockCache() *indexBlockCache {
|
||||
var idxbc indexBlockCache
|
||||
idxbc.m = make(map[uint64]indexBlockCacheEntry)
|
||||
idxbc.m = make(map[uint64]*indexBlockCacheEntry)
|
||||
idxbc.cleanerStopCh = make(chan struct{})
|
||||
idxbc.cleanerWG.Add(1)
|
||||
go func() {
|
||||
@ -248,10 +248,10 @@ var (
|
||||
func (idxbc *indexBlockCache) Get(k uint64) *indexBlock {
|
||||
atomic.AddUint64(&idxbc.requests, 1)
|
||||
idxbc.mu.RLock()
|
||||
idxbe, ok := idxbc.m[k]
|
||||
idxbe := idxbc.m[k]
|
||||
idxbc.mu.RUnlock()
|
||||
|
||||
if ok {
|
||||
if idxbe != nil {
|
||||
currentTime := atomic.LoadUint64(¤tTimestamp)
|
||||
if atomic.LoadUint64(&idxbe.lastAccessTime) != currentTime {
|
||||
atomic.StoreUint64(&idxbe.lastAccessTime, currentTime)
|
||||
@ -284,7 +284,7 @@ func (idxbc *indexBlockCache) Put(k uint64, idxb *indexBlock) bool {
|
||||
}
|
||||
|
||||
// Store idxb in the cache.
|
||||
idxbe := indexBlockCacheEntry{
|
||||
idxbe := &indexBlockCacheEntry{
|
||||
lastAccessTime: atomic.LoadUint64(¤tTimestamp),
|
||||
idxb: idxb,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user