fix(work): storage worker

This commit is contained in:
bandl 2021-10-28 11:56:05 +08:00
parent 686c032f34
commit dce8739514
2 changed files with 6 additions and 5 deletions

View File

@ -1,7 +1,6 @@
package lru
import (
"fmt"
"sync"
"time"
@ -36,7 +35,6 @@ func (l *lruTTl) setKeys(key *proto.BaseKey) int64 {
func (l *lruTTl) ttlKeyToMemoryBySecond() {
t := time.Now()
values := l.sk.PopLeft(float64(t.Unix()))
fmt.Println(len(values))
for _, val := range values {
l.memoryKey <- val.(string)

View File

@ -68,18 +68,21 @@ func (lru *SingleCache) lruTtlWork() {
}
return keys, nil
})
cleanTTlTicker := time.NewTicker(500 * time.Millisecond)
defer cleanTTlTicker.Stop()
for {
// 清理事件
<-cleanTTlTicker.C
ttlEvent := lru.lruCleanProduce.NewEvent(TtlEventName)
ttlEvent.SetValue(WorkFuncEventKey, work)
if len(lru.lruTtlManage.memoryKey) == 0 {
continue
}
ttlEvent := lru.lruCleanProduce.NewEvent(TtlEventName)
ttlEvent.SetValue(WorkFuncEventKey, work)
ttlEvent.InitWaitEvent()
lru.lruCleanProduce.Call(ctx, ttlEvent)
keys, err := ttlEvent.StartWaitEvent(time.Second * 2)
lru.lruCleanProduce.Recovery(ttlEvent)