diff --git a/pkg/lru/lru.go b/pkg/lru/lru.go index 6f4004d..9a213ec 100644 --- a/pkg/lru/lru.go +++ b/pkg/lru/lru.go @@ -11,12 +11,6 @@ import ( "sync/atomic" ) -// feat -/* -1. cleanProduce -2. 定义 LRUSingle Work 函数 - -*/ type keyBaseValue struct { key string diff --git a/pkg/lru/woker_test.go b/pkg/lru/woker_test.go new file mode 100644 index 0000000..7fa16b0 --- /dev/null +++ b/pkg/lru/woker_test.go @@ -0,0 +1,9 @@ +package lru + +import ( + "testing" +) + +func TestSingleCache_RetDriver(t *testing.T) { + +} diff --git a/pkg/lru/worker.go b/pkg/lru/worker.go index b2f2f2b..285bbcf 100644 --- a/pkg/lru/worker.go +++ b/pkg/lru/worker.go @@ -2,46 +2,29 @@ package lru import ( "context" - "gitee.com/timedb/wheatCache/pkg/errorx" "gitee.com/timedb/wheatCache/pkg/event" "log" - "time" ) func lruCleanWork() { } -func funcWork(work SingleWorkFunc, ttl time.Duration) interface{} { - t := time.NewTimer(ttl) - - resultCh := make(chan interface{}) - go func() { - resultCh <- work() - }() - - select { - case <-t.C: - return errorx.TimeOutErr() - case res := <-resultCh: - return res - } -} - func (lru *singleCache) lruSingleWork() interface{} { ctx := context.Background() for { - event := lru.lruConsumer.Receive(ctx) + eventKon := lru.lruConsumer.Receive(ctx) - worFunc, ok := event.GetValue(WorkFuncEventCtxKey) + worFunc, ok := eventKon.GetValue(WorkFuncEventCtxKey) if !ok { continue } switch worFunc.(type) { - case SingleWorkFunc: - _, err := event.ExecWorkAndSendResult(worFunc.(*event)) - log.Println(err) + case event.EventWorkFunc: + eventKon.ExecWorkAndSendResult(worFunc.(event.EventWorkFunc)) + default: + log.Print("this is debug ") } } }