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:
authorKamil Trzciński <ayufan@ayufan.eu>2020-10-12 15:35:05 +0300
committerKamil Trzciński <ayufan@ayufan.eu>2020-10-13 00:13:32 +0300
commit96dc955a4c718f0cd8be2874252bec7e28c46e82 (patch)
tree3911296dab0a674445ce828e37ff06b0f37c8d97
parent6bcdae98620236e97c9da1ca50bcd8dc837d8bd5 (diff)
Rename `namespace` to `cacheNamespace`
-rw-r--r--internal/vfs/zip/archive.go18
-rw-r--r--internal/vfs/zip/lru_cache.go6
2 files changed, 12 insertions, 12 deletions
diff --git a/internal/vfs/zip/archive.go b/internal/vfs/zip/archive.go
index 6675e199..c91993c8 100644
--- a/internal/vfs/zip/archive.go
+++ b/internal/vfs/zip/archive.go
@@ -48,7 +48,7 @@ type zipArchive struct {
done chan struct{}
openTimeout time.Duration
- namespace string
+ cacheNamespace string
resource *httprange.Resource
reader *httprange.RangedReader
@@ -60,12 +60,12 @@ type zipArchive struct {
func newArchive(fs *zipVFS, path string, openTimeout time.Duration) *zipArchive {
return &zipArchive{
- fs: fs,
- path: path,
- done: make(chan struct{}),
- files: make(map[string]*zip.File),
- openTimeout: openTimeout,
- namespace: strconv.FormatInt(atomic.AddInt64(&fs.archiveCount, 1), 10) + ":",
+ fs: fs,
+ path: path,
+ done: make(chan struct{}),
+ files: make(map[string]*zip.File),
+ openTimeout: openTimeout,
+ cacheNamespace: strconv.FormatInt(atomic.AddInt64(&fs.archiveCount, 1), 10) + ":",
}
}
@@ -172,7 +172,7 @@ func (a *zipArchive) Open(ctx context.Context, name string) (vfs.File, error) {
return nil, errNotFile
}
- dataOffset, err := a.fs.dataOffsetCache.findOrFetch(a.namespace, name, func() (interface{}, error) {
+ dataOffset, err := a.fs.dataOffsetCache.findOrFetch(a.cacheNamespace, name, func() (interface{}, error) {
return file.DataOffset()
})
if err != nil {
@@ -213,7 +213,7 @@ func (a *zipArchive) Readlink(ctx context.Context, name string) (string, error)
return "", errNotSymlink
}
- symlinkValue, err := a.fs.readlinkCache.findOrFetch(a.namespace, name, func() (interface{}, error) {
+ symlinkValue, err := a.fs.readlinkCache.findOrFetch(a.cacheNamespace, name, func() (interface{}, error) {
rc, err := file.Open()
if err != nil {
return nil, err
diff --git a/internal/vfs/zip/lru_cache.go b/internal/vfs/zip/lru_cache.go
index 01d16d67..62d252c4 100644
--- a/internal/vfs/zip/lru_cache.go
+++ b/internal/vfs/zip/lru_cache.go
@@ -29,8 +29,8 @@ func newLruCache(op string, maxEntries uint32, duration time.Duration) *lruCache
}
}
-func (c *lruCache) findOrFetch(namespace, key string, fetchFn func() (interface{}, error)) (interface{}, error) {
- item := c.cache.Get(namespace + key)
+func (c *lruCache) findOrFetch(cacheNamespace, key string, fetchFn func() (interface{}, error)) (interface{}, error) {
+ item := c.cache.Get(cacheNamespace + key)
if item != nil && !item.Expired() {
metrics.ZipCacheRequests.WithLabelValues(c.op, "hit").Inc()
@@ -46,6 +46,6 @@ func (c *lruCache) findOrFetch(namespace, key string, fetchFn func() (interface{
metrics.ZipCacheRequests.WithLabelValues(c.op, "miss").Inc()
metrics.ZipCachedEntries.WithLabelValues(c.op).Inc()
- c.cache.Set(namespace+key, value, c.duration)
+ c.cache.Set(cacheNamespace+key, value, c.duration)
return value, nil
}