From 3eb515325d542b1ee7b1cf6847016b1c3a4684f0 Mon Sep 17 00:00:00 2001 From: bandl <1658002533@qq.com> Date: Thu, 11 Nov 2021 22:32:14 +0800 Subject: [PATCH] feat(lru): update lru event2 --- pkg/lru/lru.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pkg/lru/lru.go b/pkg/lru/lru.go index 951d2dc..b51df88 100644 --- a/pkg/lru/lru.go +++ b/pkg/lru/lru.go @@ -7,6 +7,7 @@ import ( _ "gitee.com/wheat-os/wheatCache/conf" "gitee.com/wheat-os/wheatCache/pkg/errorx" "gitee.com/wheat-os/wheatCache/pkg/event" + "gitee.com/wheat-os/wheatCache/pkg/event2" "gitee.com/wheat-os/wheatCache/pkg/middle" "gitee.com/wheat-os/wheatCache/pkg/proto" "gitee.com/wheat-os/wheatCache/pkg/structure" @@ -29,9 +30,9 @@ type SingleCache struct { lruMaxDiverSize int lruTtlManage *lruTTl // 定时清理器 - lruDriver event.DriverInterface - lruConsumer event.ConsumerInterface - lruCleanProduce event.ProduceInterface // 发送清理事件 + lruDriver event2.DriverInterface + lruConsumer event2.ConsumerInterface + lruCleanProduce event2.ProduceInterface // 发送清理事件 middleProduce event.ProduceInterface // 中间件驱动 } @@ -76,7 +77,7 @@ func cacheInit() (int64, int64, int, int) { // NewLRUCache lru初始化 func NewLRUCache() *SingleCache { maxSize, clearSize, maxDriverSize, detachNum := cacheInit() - lruDriver := event.NewDriver(maxDriverSize) + lruDriver := event2.NewDriver(maxDriverSize) lruCacheOnce.Do(func() { lru := &SingleCache{ maxsize: maxSize, @@ -86,8 +87,8 @@ func NewLRUCache() *SingleCache { lruMap: make(map[string]*list.Element), lruMaxDiverSize: maxDriverSize, lruDriver: lruDriver, - lruConsumer: event.NewConsumer(lruDriver), - lruCleanProduce: event.NewProduce(lruDriver), + lruConsumer: event2.NewConsumer(lruDriver), + lruCleanProduce: event2.NewProduce(lruDriver), middleProduce: event.NewProduce(middle.NewMiddleWare().GetEventDriver()), lruTtlManage: newLruTTl(detachNum), } @@ -103,7 +104,7 @@ func NewLRUCache() *SingleCache { } // GetDriver 获取驱动 -func (lru *SingleCache) GetDriver() event.DriverInterface { +func (lru *SingleCache) GetDriver() event2.DriverInterface { return lru.lruDriver }