diff options
| -rw-r--r-- | weed/s3api/s3api_bucket_config.go | 8 | ||||
| -rw-r--r-- | weed/s3api/s3api_server.go | 2 |
2 files changed, 7 insertions, 3 deletions
diff --git a/weed/s3api/s3api_bucket_config.go b/weed/s3api/s3api_bucket_config.go index 05abf3863..1c2bcbd98 100644 --- a/weed/s3api/s3api_bucket_config.go +++ b/weed/s3api/s3api_bucket_config.go @@ -30,13 +30,17 @@ type BucketConfig struct { } // BucketConfigCache provides caching for bucket configurations +// Cache entries are automatically updated/invalidated through metadata subscription events, +// so TTL serves as a safety fallback rather than the primary consistency mechanism type BucketConfigCache struct { cache map[string]*BucketConfig mutex sync.RWMutex - ttl time.Duration + ttl time.Duration // Safety fallback TTL; real-time consistency maintained via events } // NewBucketConfigCache creates a new bucket configuration cache +// TTL can be set to a longer duration since cache consistency is maintained +// through real-time metadata subscription events rather than TTL expiration func NewBucketConfigCache(ttl time.Duration) *BucketConfigCache { return &BucketConfigCache{ cache: make(map[string]*BucketConfig), @@ -54,7 +58,7 @@ func (bcc *BucketConfigCache) Get(bucket string) (*BucketConfig, bool) { return nil, false } - // Check if cache entry is expired + // Check if cache entry is expired (safety fallback; entries are normally updated via events) if time.Since(config.LastModified) > bcc.ttl { return nil, false } diff --git a/weed/s3api/s3api_server.go b/weed/s3api/s3api_server.go index 5d113c645..db2f42c8b 100644 --- a/weed/s3api/s3api_server.go +++ b/weed/s3api/s3api_server.go @@ -88,7 +88,7 @@ func NewS3ApiServerWithStore(router *mux.Router, option *S3ApiServerOption, expl filerGuard: security.NewGuard([]string{}, signingKey, expiresAfterSec, readSigningKey, readExpiresAfterSec), cb: NewCircuitBreaker(option), credentialManager: iam.credentialManager, - bucketConfigCache: NewBucketConfigCache(5 * time.Minute), + bucketConfigCache: NewBucketConfigCache(60 * time.Minute), // Increased TTL since cache is now event-driven } if option.Config != "" { |
