Skip to content

Commit

Permalink
fix expiration key
Browse files Browse the repository at this point in the history
  • Loading branch information
FZambia committed Nov 25, 2023
1 parent bf29138 commit 369064e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions broker_memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,10 @@ func (b *MemoryBroker) getResultFromCache(ch string, key string) (StreamPosition
func (b *MemoryBroker) saveResultToCache(ch string, key string, sp StreamPosition) {
b.resultCacheMu.Lock()
defer b.resultCacheMu.Unlock()
b.resultCache[ch+"_"+key] = sp
cacheKey := ch + "_" + key
b.resultCache[cacheKey] = sp
expireAt := time.Now().Unix() + b.resultKeyExpSeconds
heap.Push(&b.resultExpireQueue, &priority.Item{Value: key, Priority: expireAt})
heap.Push(&b.resultExpireQueue, &priority.Item{Value: cacheKey, Priority: expireAt})
if b.nextExpireCheck == 0 || b.nextExpireCheck > expireAt {
b.nextExpireCheck = expireAt
}
Expand Down

0 comments on commit 369064e

Please sign in to comment.