From e9f38a49e4a8fc2db2d6fab50710ea4b8e1bc6e1 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Fri, 1 Mar 2024 16:09:33 +0300 Subject: [PATCH] [#306] Fix forming key for bucket cache Signed-off-by: Denis Kirillov --- api/cache/buckets.go | 4 ++-- api/layer/cache.go | 4 ++-- api/layer/layer.go | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/api/cache/buckets.go b/api/cache/buckets.go index a8a6af83..5271b8e1 100644 --- a/api/cache/buckets.go +++ b/api/cache/buckets.go @@ -65,6 +65,6 @@ func (o *BucketCache) Delete(bkt *data.BucketInfo) bool { return o.cache.Remove(formKey(bkt.Zone, bkt.Name)) } -func formKey(ns, name string) string { - return name + "." + ns +func formKey(zone, name string) string { + return name + "." + zone } diff --git a/api/layer/cache.go b/api/layer/cache.go index 02f095a1..23cbd9ab 100644 --- a/api/layer/cache.go +++ b/api/layer/cache.go @@ -60,8 +60,8 @@ func NewCache(cfg *CachesConfig) *Cache { } } -func (c *Cache) GetBucket(ns, name string) *data.BucketInfo { - return c.bucketCache.Get(ns, name) +func (c *Cache) GetBucket(zone, name string) *data.BucketInfo { + return c.bucketCache.Get(zone, name) } func (c *Cache) PutBucket(bktInfo *data.BucketInfo) { diff --git a/api/layer/layer.go b/api/layer/layer.go index 2b986276..f44fc3f3 100644 --- a/api/layer/layer.go +++ b/api/layer/layer.go @@ -404,8 +404,9 @@ func (n *layer) GetBucketInfo(ctx context.Context, name string) (*data.BucketInf } reqInfo := middleware.GetReqInfo(ctx) + zone, _ := n.features.FormContainerZone(reqInfo.Namespace) - if bktInfo := n.cache.GetBucket(reqInfo.Namespace, name); bktInfo != nil { + if bktInfo := n.cache.GetBucket(zone, name); bktInfo != nil { return bktInfo, nil }