forked from p53841790/wheat-cache
fix(work): storage worker
This commit is contained in:
parent
686c032f34
commit
dce8739514
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue