Skip to content

Commit

Permalink
Introduce check for local and memory stores before wrapping with cach…
Browse files Browse the repository at this point in the history
…ing layer
  • Loading branch information
gruuya committed Mar 11, 2024
1 parent b33bbf9 commit 4ecaf2a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/catalog/metastore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ impl Metastore {
})?
.clone();

if let Some(ref cache) = self.object_store_cache {
if (location.starts_with("file://") || location.starts_with("memory://"))
&& let Some(ref cache) = self.object_store_cache
{
// Wrap the non-local store with the caching layer
store = cache.wrap_store(store);
}

Expand Down
10 changes: 5 additions & 5 deletions src/config/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,15 +386,15 @@ impl Default for Metrics {
pub struct ObjectCacheProperties {
pub capacity: u64,
pub min_fetch_size: u64,
pub ttl_s: u64,
pub ttl: u64,
}

impl Default for ObjectCacheProperties {
fn default() -> Self {
Self {
capacity: DEFAULT_CACHE_CAPACITY,
min_fetch_size: DEFAULT_MIN_FETCH_SIZE,
ttl_s: DEFAULT_CACHE_ENTRY_TTL.as_secs(),
ttl: DEFAULT_CACHE_ENTRY_TTL.as_secs(),
}
}
}
Expand All @@ -409,7 +409,7 @@ impl ObjectCacheProperties {
&path,
self.min_fetch_size,
self.capacity,
Duration::from_secs(self.ttl_s),
Duration::from_secs(self.ttl),
))
}
}
Expand Down Expand Up @@ -557,7 +557,7 @@ dsn = "postgresql://user:pass@localhost:5432/somedb"
[misc.object_store_cache]
min_fetch_size = 4096
ttl_s = 10
ttl = 10
"#;

const TEST_CONFIG_BASIC: &str = r#"
Expand Down Expand Up @@ -630,7 +630,7 @@ cache_control = "private, max-age=86400"
#[case::basic_s3(TEST_CONFIG_S3, None)]
#[case::basic_s3_with_cache(
TEST_CONFIG_S3_WITH_CACHE,
Some(ObjectCacheProperties{ capacity: DEFAULT_CACHE_CAPACITY, min_fetch_size: 4096, ttl_s: 10 }))
Some(ObjectCacheProperties{ capacity: DEFAULT_CACHE_CAPACITY, min_fetch_size: 4096, ttl: 10 }))
]
fn test_parse_config_with_s3(
#[case] config_str: &str,
Expand Down

0 comments on commit 4ecaf2a

Please sign in to comment.