From 509b829c5bbaa36adf7f1adff6e96c52029923b4 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Mon, 21 Apr 2025 14:44:23 +0800 Subject: [PATCH] =?UTF-8?q?s3=20=E4=BF=AE=E5=A4=8D=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E9=94=AE=E9=81=BF=E5=85=8D=E8=A2=AB=E9=80=BB=E8=BE=91=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fs/s3_adapter.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/s3_adapter.go b/fs/s3_adapter.go index f7455d8..9788ba1 100644 --- a/fs/s3_adapter.go +++ b/fs/s3_adapter.go @@ -53,8 +53,8 @@ func (s *S3Adapter) GetFileList(ctx context.Context, dirPath string, relDt time. span.SetAttributes(attribute.String("path", dirPath)) span.SetAttributes(attribute.String("relativeDate", relDt.Format("2006-01-02"))) - key := fmt.Sprintf("%s_%s", dirPath, relDt.Format("2006-01-02")) - if cachedInterface, ok := s.cache.Load(key); ok { + cacheKey := fmt.Sprintf("%s_%s", dirPath, relDt.Format("2006-01-02")) + if cachedInterface, ok := s.cache.Load(cacheKey); ok { cachedItem := cachedInterface.(cacheItem) if time.Now().Before(cachedItem.expires) { span.SetAttributes(attribute.Bool("cache.hit", true)) @@ -62,7 +62,7 @@ func (s *S3Adapter) GetFileList(ctx context.Context, dirPath string, relDt time. } } - mutexKey := fmt.Sprintf("lock_%s", key) + mutexKey := fmt.Sprintf("lock_%s", cacheKey) mutex, _ := s.cache.LoadOrStore(mutexKey, &sync.Mutex{}) lock := mutex.(*sync.Mutex) defer func() { @@ -72,7 +72,7 @@ func (s *S3Adapter) GetFileList(ctx context.Context, dirPath string, relDt time. }() lock.Lock() - if cachedInterface, ok := s.cache.Load(key); ok { + if cachedInterface, ok := s.cache.Load(cacheKey); ok { cachedItem := cachedInterface.(cacheItem) if time.Now().Before(cachedItem.expires) { span.SetAttributes(attribute.Bool("cache.hit", true)) @@ -168,7 +168,7 @@ func (s *S3Adapter) GetFileList(ctx context.Context, dirPath string, relDt time. data: fileList, expires: time.Now().Add(10 * time.Second), } - s.cache.Store(key, cacheItem) + s.cache.Store(cacheKey, cacheItem) return fileList, nil }