You've already forked VptPassiveAdapter
日志
This commit is contained in:
@@ -3,11 +3,12 @@ package fs
|
||||
import (
|
||||
"ZhenTuLocalPassiveAdapter/config"
|
||||
"ZhenTuLocalPassiveAdapter/dto"
|
||||
"ZhenTuLocalPassiveAdapter/logger"
|
||||
"ZhenTuLocalPassiveAdapter/util"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/aws/aws-sdk-go-v2/credentials"
|
||||
"log"
|
||||
"go.uber.org/zap"
|
||||
"path"
|
||||
"sort"
|
||||
"sync"
|
||||
@@ -63,9 +64,9 @@ func (s *S3Adapter) GetFileList(ctx context.Context, dirPath string, relDt time.
|
||||
cacheKey := fmt.Sprintf("%s_%s", dirPath, relDt.Format("2006-01-02"))
|
||||
if cachedInterface, ok := s3Cache.Load(cacheKey); ok {
|
||||
cachedItem := cachedInterface.(cacheItem)
|
||||
log.Println("缓存过期时间", cachedItem.expires.Sub(time.Now()))
|
||||
logger.Debug("缓存过期时间", zap.Duration("expiresIn", cachedItem.expires.Sub(time.Now())))
|
||||
if time.Now().Before(cachedItem.expires) {
|
||||
log.Println("获取已缓存列表", cacheKey)
|
||||
logger.Debug("获取已缓存列表", zap.String("cacheKey", cacheKey))
|
||||
span.SetAttributes(attribute.Bool("cache.hit", true))
|
||||
return cachedItem.data, nil
|
||||
}
|
||||
@@ -83,9 +84,9 @@ func (s *S3Adapter) GetFileList(ctx context.Context, dirPath string, relDt time.
|
||||
|
||||
if cachedInterface, ok := s3Cache.Load(cacheKey); ok {
|
||||
cachedItem := cachedInterface.(cacheItem)
|
||||
log.Println("缓存过期时间", cachedItem.expires.Sub(time.Now()))
|
||||
logger.Debug("缓存过期时间", zap.Duration("expiresIn", cachedItem.expires.Sub(time.Now())))
|
||||
if time.Now().Before(cachedItem.expires) {
|
||||
log.Println("过锁后获取已缓存列表", cacheKey)
|
||||
logger.Debug("过锁后获取已缓存列表", zap.String("cacheKey", cacheKey))
|
||||
span.SetAttributes(attribute.Bool("s3Cache.hit", true))
|
||||
return cachedItem.data, nil
|
||||
}
|
||||
@@ -144,7 +145,7 @@ func (s *S3Adapter) GetFileList(ctx context.Context, dirPath string, relDt time.
|
||||
if err != nil {
|
||||
span.SetAttributes(attribute.String("error", err.Error()))
|
||||
span.SetStatus(codes.Error, "生成预签名URL失败")
|
||||
log.Println("Error presigning GetObject request:", err)
|
||||
logger.Error("生成预签名URL失败", zap.Error(err))
|
||||
continue
|
||||
}
|
||||
fileList = append(fileList, dto.File{
|
||||
@@ -174,7 +175,7 @@ func (s *S3Adapter) GetFileList(ctx context.Context, dirPath string, relDt time.
|
||||
expires: time.Now().Add(30 * time.Second),
|
||||
}
|
||||
s3Cache.Store(cacheKey, cacheItem)
|
||||
log.Println("缓存文件列表", cacheKey)
|
||||
logger.Debug("缓存文件列表", zap.String("cacheKey", cacheKey))
|
||||
|
||||
return fileList, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user