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 }