Skip to content

Commit

Permalink
make sure the in-memory cache is only used for request coalescing
Browse files Browse the repository at this point in the history
  • Loading branch information
Swatinem committed Jan 24, 2023
1 parent f79f167 commit 2028ca2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 9 additions & 2 deletions crates/symbolicator-service/src/services/cacher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::fmt;
use std::path::{Path, PathBuf};
use std::sync::atomic::Ordering;
use std::sync::Arc;
use std::time::Duration;

use anyhow::Context;
use futures::future::BoxFuture;
Expand Down Expand Up @@ -60,10 +61,16 @@ impl<T: CacheItemRequest> Clone for Cacher<T> {

impl<T: CacheItemRequest> Cacher<T> {
pub fn new(config: Cache, shared_cache: SharedCacheRef) -> Self {
// TODO: eventually hook up configuration to this
// The capacity(0) and ttl(0) make sure we are not (yet) reusing in-memory caches, except
// for request coalescing right now.
let cache = InMemoryCache::builder()
.max_capacity(0)
.time_to_live(Duration::ZERO)
.build();
Cacher {
config,
// TODO: eventually hook up configuration to this
cache: InMemoryCache::new(0),
cache,
refreshes: Default::default(),
shared_cache,
}
Expand Down
4 changes: 1 addition & 3 deletions crates/symbolicator-service/tests/integration/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,6 @@ fn get_files(path: impl AsRef<Path>) -> Vec<(String, u64)> {
}

/// Tests caching side-effects, like cache files written and hits to the symbol source.
#[allow(clippy::if_same_then_else)]
#[tokio::test]
async fn test_basic_windows() {
let (modules, stacktraces) = request_fixture();
Expand Down Expand Up @@ -560,8 +559,7 @@ async fn test_basic_windows() {
} else {
// we are downloading twice: once for the objects_meta request, and once
// again for the objects/symcache request
// FIXME: well with in-memory caching, we are only requesting once
(1, 1)
(2, 1)
};

assert_eq!(&hits, &[
Expand Down

0 comments on commit 2028ca2

Please sign in to comment.