From 3636c3952ac09aaed08372f114fcb74bde5b82bb Mon Sep 17 00:00:00 2001 From: xing Date: Mon, 19 Sep 2022 20:34:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- actions/common/common.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/actions/common/common.go b/actions/common/common.go index c7bccdd..b1a4cd9 100644 --- a/actions/common/common.go +++ b/actions/common/common.go @@ -14,12 +14,12 @@ import ( var PostsCache sync.Map var PostContextCache sync.Map -var archivesCaches *Arch[models.PostArchive] +var archivesCaches *Arch var categoryCaches *cache.SliceCache[models.WpTermsMy] var recentPostsCaches *cache.SliceCache[models.WpPosts] func InitCache() { - archivesCaches = &Arch[models.PostArchive]{ + archivesCaches = &Arch{ mutex: &sync.Mutex{}, setCacheFunc: archives, } @@ -27,15 +27,14 @@ func InitCache() { recentPostsCaches = cache.NewSliceCache[models.WpPosts](recentPosts, vars.Conf.RecentPostCacheTime) } -type Arch[T any] struct { - cache.SliceCache[T] - data []T +type Arch struct { + data []models.PostArchive mutex *sync.Mutex - setCacheFunc func() ([]T, error) + setCacheFunc func() ([]models.PostArchive, error) month time.Month } -func (c *Arch[T]) GetCache() []T { +func (c *Arch) GetCache() []models.PostArchive { l := len(c.data) m := time.Now().Month() if l > 0 && c.month != m || l < 1 {