@@ -29,11 +29,7 @@ impl<T> S3CachingProxy<T> {
2929 /// Creates a new caching proxy wrapping an S3 implementation.
3030 ///
3131 /// Pass `None` for `cache` to disable caching (passthrough mode).
32- pub fn new (
33- inner : T ,
34- cache : Option < Arc < S3Cache > > ,
35- max_cacheable_size : usize ,
36- ) -> Self {
32+ pub fn new ( inner : T , cache : Option < Arc < S3Cache > > , max_cacheable_size : usize ) -> Self {
3733 let statistics = UniqueRequestedObjectsStatisticsTracker :: new ( ) ;
3834
3935 Self {
@@ -167,19 +163,19 @@ impl<T: S3 + Send + Sync> S3 for S3CachingProxy<T> {
167163 let cache_key = CacheKey :: new ( bucket. clone ( ) , key. clone ( ) , range_str. clone ( ) , version_id) ;
168164
169165 // Check cache
170- if let Some ( cache) = & self . cache {
171- if let Some ( cached) = cache. get ( & cache_key) . await {
172- debug ! ( bucket = %bucket, key = %key, "cache hit" ) ;
173- telemetry:: record_cache_hit ( cached. content_length ( ) as u64 ) ;
174- cache. report_stats ( ) . await ;
175-
176- let bytes_len = cached. content_length ( ) ;
177- if self . statistics . insert ( & key, bytes_len) {
178- telemetry:: record_unique_requested ( bytes_len as u64 ) ;
179- }
166+ if let Some ( cache) = & self . cache
167+ && let Some ( cached) = cache. get ( & cache_key) . await
168+ {
169+ debug ! ( bucket = %bucket, key = %key, "cache hit" ) ;
170+ telemetry:: record_cache_hit ( cached. content_length ( ) as u64 ) ;
171+ cache. report_stats ( ) . await ;
180172
181- return Ok ( S3Response :: new ( cached. to_s3_object ( ) ) ) ;
173+ let bytes_len = cached. content_length ( ) ;
174+ if self . statistics . insert ( & key, bytes_len) {
175+ telemetry:: record_unique_requested ( bytes_len as u64 ) ;
182176 }
177+
178+ return Ok ( S3Response :: new ( cached. to_s3_object ( ) ) ) ;
183179 }
184180 debug ! ( bucket = %bucket, key = %key, "cache miss" ) ;
185181
0 commit comments