Skip to content
This repository was archived by the owner on Feb 6, 2026. It is now read-only.

Commit 30be50d

Browse files
committed
fix: adjust cache settings
1 parent 4139a87 commit 30be50d

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

lib/dal/src/workspace_snapshot.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,11 +1224,6 @@ impl WorkspaceSnapshot {
12241224
// This is the key for an entry in a map.
12251225
EdgeWeightKind::Contain(Some(key)) => hasher.update(key.as_bytes()),
12261226

1227-
// This is the kind of the action.
1228-
EdgeWeightKind::ActionPrototype(kind) => {
1229-
hasher.update(kind.to_string().as_bytes())
1230-
}
1231-
12321227
EdgeWeightKind::Use { is_default } => {
12331228
hasher.update(is_default.to_string().as_bytes())
12341229
}
@@ -1241,6 +1236,7 @@ impl WorkspaceSnapshot {
12411236
// in the edge itself.
12421237
EdgeWeightKind::AuthenticationPrototype
12431238
| EdgeWeightKind::Action
1239+
| EdgeWeightKind::ActionPrototype
12441240
| EdgeWeightKind::Contain(None)
12451241
| EdgeWeightKind::FrameContains
12461242
| EdgeWeightKind::PrototypeArgument

lib/si-layer-cache/src/layer_cache.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::{collections::HashMap, fmt::Display, path::Path, sync::Arc};
2+
use telemetry::prelude::*;
23

34
use serde::{de::DeserializeOwned, Serialize};
45
use si_data_pg::{PgPool, PgPoolConfig};
@@ -49,6 +50,7 @@ where
4950
Some(memory_value) => Some(memory_value),
5051
None => match self.disk_cache.get(&key)? {
5152
Some(value) => {
53+
info!("hitting sled");
5254
let deserialized: V = postcard::from_bytes(&value)?;
5355

5456
self.memory_cache.insert(key, deserialized.clone()).await;
@@ -57,6 +59,7 @@ where
5759
None => match self.pg.get(&key).await? {
5860
Some(value) => {
5961
let deserialized: V = postcard::from_bytes(&value)?;
62+
info!("hitting pg");
6063

6164
self.memory_cache
6265
.insert(key.clone(), deserialized.clone())

lib/si-layer-cache/src/memory_cache.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
use std::sync::Arc;
1+
use std::{sync::Arc, time::Duration};
22

33
use moka::future::Cache;
44
use serde::{de::DeserializeOwned, Serialize};
55

6+
const DEFAULT_SIZE: u64 = 65_536;
7+
const DEFAULT_TTL: Duration = Duration::from_secs(60 * 60 * 24 * 2);
8+
const DEFAULT_TTI: Duration = Duration::from_secs(60 * 60 * 24);
9+
610
#[derive(Clone, Debug)]
711
pub struct MemoryCache<V>
812
where
@@ -26,7 +30,11 @@ where
2630
{
2731
pub fn new() -> Self {
2832
Self {
29-
cache: Cache::new(u64::MAX),
33+
cache: Cache::builder()
34+
.max_capacity(DEFAULT_SIZE)
35+
.time_to_idle(DEFAULT_TTI)
36+
.time_to_live(DEFAULT_TTL)
37+
.build(),
3038
}
3139
}
3240

0 commit comments

Comments
 (0)