Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessio Caiazza <acaiazza@gitlab.com>2023-11-14 23:29:35 +0300
committerAlessio Caiazza <acaiazza@gitlab.com>2023-11-14 23:29:35 +0300
commit4037db271d552bd61f83abc6d366f33b23e9a302 (patch)
treec30e71ff937e33cf19b463776d8f557c576cc939 /internal
parentdceac124eba93ceb3a12fb31cec49e4c51222858 (diff)
parent682415d166b44b2ae6ca1904b5849b32d63396c2 (diff)
Merge branch 'upgrade-ccache-v3' into 'master'
Update module github.com/karlseguin/ccache/v2 to v3 See merge request https://gitlab.com/gitlab-org/gitlab-pages/-/merge_requests/920 Merged-by: Alessio Caiazza <acaiazza@gitlab.com> Approved-by: Alessio Caiazza <acaiazza@gitlab.com> Reviewed-by: Naman Jagdish Gala <ngala@gitlab.com> Co-authored-by: Jaime Martinez <jmartinez@gitlab.com> Co-authored-by: GitLab Renovate Bot <gitlab-bot@gitlab.com>
Diffstat (limited to 'internal')
-rw-r--r--internal/lru/lru.go10
-rw-r--r--internal/vfs/zip/vfs.go2
2 files changed, 6 insertions, 6 deletions
diff --git a/internal/lru/lru.go b/internal/lru/lru.go
index dafb5347..1069bd7f 100644
--- a/internal/lru/lru.go
+++ b/internal/lru/lru.go
@@ -3,7 +3,7 @@ package lru
import (
"time"
- "github.com/karlseguin/ccache/v2"
+ "github.com/karlseguin/ccache/v3"
"github.com/prometheus/client_golang/prometheus"
)
@@ -30,7 +30,7 @@ type Cache struct {
op string
duration time.Duration
maxSize int64
- cache *ccache.Cache
+ cache *ccache.Cache[any]
metricCachedEntries *prometheus.GaugeVec
metricCacheRequests *prometheus.CounterVec
}
@@ -47,11 +47,11 @@ func New(op string, opts ...Option) *Cache {
opt(c)
}
- configuration := ccache.Configure()
+ configuration := ccache.Configure[any]()
configuration.MaxSize(c.maxSize)
configuration.ItemsToPrune(uint32(c.maxSize) / itemsToPruneDiv)
configuration.GetsPerPromote(getsPerPromote) // if item gets requested frequently promote it
- configuration.OnDelete(func(*ccache.Item) {
+ configuration.OnDelete(func(*ccache.Item[any]) {
if c.metricCachedEntries != nil {
c.metricCachedEntries.WithLabelValues(op).Dec()
}
@@ -64,7 +64,7 @@ func New(op string, opts ...Option) *Cache {
// FindOrFetch will try to get the item from the cache if exists and is not expired.
// If it can't find it, it will call fetchFn to retrieve the item and cache it.
-func (c *Cache) FindOrFetch(cacheNamespace, key string, fetchFn func() (interface{}, error)) (interface{}, error) {
+func (c *Cache) FindOrFetch(cacheNamespace, key string, fetchFn func() (any, error)) (any, error) {
item := c.cache.Get(cacheNamespace + key)
if item != nil && !item.Expired() {
diff --git a/internal/vfs/zip/vfs.go b/internal/vfs/zip/vfs.go
index 6b42e627..b2207bba 100644
--- a/internal/vfs/zip/vfs.go
+++ b/internal/vfs/zip/vfs.go
@@ -38,7 +38,7 @@ var (
)
type lruCache interface {
- FindOrFetch(cacheNamespace, key string, fetchFn func() (interface{}, error)) (interface{}, error)
+ FindOrFetch(cacheNamespace, key string, fetchFn func() (any, error)) (any, error)
}
// zipVFS is a simple cached implementation of the vfs.VFS interface