aboutsummaryrefslogtreecommitdiffstats
path: root/modules/cache/cache_twoqueue.go
diff options
context:
space:
mode:
authorharryzcy <harry@harryzheng.com>2023-07-13 22:00:31 -0500
committerGitHub <noreply@github.com>2023-07-14 11:00:31 +0800
commitc5e187c389b35b9e080a3187b93a775a3c81e585 (patch)
tree7c65ee5aaf56b6f53a96742286d98119dba5b13b /modules/cache/cache_twoqueue.go
parentb81c01305714ceca818ccb91d19dada6469e658c (diff)
downloadgitea-c5e187c389b35b9e080a3187b93a775a3c81e585.tar.gz
gitea-c5e187c389b35b9e080a3187b93a775a3c81e585.zip
Upgrade go dependencies (#25819)
Diffstat (limited to 'modules/cache/cache_twoqueue.go')
-rw-r--r--modules/cache/cache_twoqueue.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/modules/cache/cache_twoqueue.go b/modules/cache/cache_twoqueue.go
index 184db25573..f9de2563ec 100644
--- a/modules/cache/cache_twoqueue.go
+++ b/modules/cache/cache_twoqueue.go
@@ -11,13 +11,13 @@ import (
"code.gitea.io/gitea/modules/json"
mc "gitea.com/go-chi/cache"
- lru "github.com/hashicorp/golang-lru"
+ lru "github.com/hashicorp/golang-lru/v2"
)
// TwoQueueCache represents a LRU 2Q cache adapter implementation
type TwoQueueCache struct {
lock sync.Mutex
- cache *lru.TwoQueueCache
+ cache *lru.TwoQueueCache[string, any]
interval int
}
@@ -146,7 +146,7 @@ func (c *TwoQueueCache) Flush() error {
return nil
}
-func (c *TwoQueueCache) checkAndInvalidate(key any) {
+func (c *TwoQueueCache) checkAndInvalidate(key string) {
c.lock.Lock()
defer c.lock.Unlock()
cached, ok := c.cache.Peek(key)
@@ -155,7 +155,7 @@ func (c *TwoQueueCache) checkAndInvalidate(key any) {
}
item, ok := cached.(*MemoryItem)
if !ok || item.hasExpired() {
- c.cache.Remove(item)
+ c.cache.Remove(key)
}
}
@@ -187,9 +187,9 @@ func (c *TwoQueueCache) StartAndGC(opts mc.Options) error {
GhostRatio: lru.Default2QGhostEntries,
}
_ = json.Unmarshal([]byte(opts.AdapterConfig), cfg)
- c.cache, err = lru.New2QParams(cfg.Size, cfg.RecentRatio, cfg.GhostRatio)
+ c.cache, err = lru.New2QParams[string, any](cfg.Size, cfg.RecentRatio, cfg.GhostRatio)
} else {
- c.cache, err = lru.New2Q(size)
+ c.cache, err = lru.New2Q[string, any](size)
}
c.interval = opts.Interval
if c.interval > 0 {