From dcce00a32d71011ca9adf5a39d923391cff37991 Mon Sep 17 00:00:00 2001
From: HuangJiaLuo <1820799930@qq.com>
Date: Sat, 9 Oct 2021 22:08:09 +0800
Subject: [PATCH] feat(lru): feat the function of launching the cleanWorkFunc
 to driver

---
 pkg/lru/cleanwork.go | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 pkg/lru/cleanwork.go

diff --git a/pkg/lru/cleanwork.go b/pkg/lru/cleanwork.go
new file mode 100644
index 0000000..af787dc
--- /dev/null
+++ b/pkg/lru/cleanwork.go
@@ -0,0 +1,28 @@
+package lru
+
+import (
+	"context"
+	"gitee.com/timedb/wheatCache/pkg/event"
+	"gitee.com/timedb/wheatCache/pkg/proto"
+	"time"
+)
+
+type cleanWorkSingle struct {
+	timeOut time.Duration
+	lru *SingleCache
+}
+
+func (clean *cleanWorkSingle) cleanWork() (*proto.ReduceResponse, error) {
+	cxt := context.Background()
+	lruCleanEvent := event.NewEvent(CleanEventName)
+	lruCleanEvent.InitWaitEvent()
+	lruCleanEvent.SetValue(WorkFuncEventKey, clean.lru.DelToClearSize())
+	clean.lru.lruCleanProduce.Call(cxt, lruCleanEvent)
+	resp, err := lruCleanEvent.StartWaitEvent(clean.timeOut)
+	if err != nil{
+		return nil, err
+	}
+	return &proto.ReduceResponse{
+		Result: resp.(string),
+	}, nil
+}
\ No newline at end of file