Skip to content

Commit 30490f4

Browse files
committed
make the ttl for the storage mapping of the root storage much higher
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent f791ad1 commit 30490f4

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/storage_mapping.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,15 @@ struct CachedAccess {
3232
impl CachedAccess {
3333
pub fn new(access: Vec<UserStorageAccess>) -> Self {
3434
let mut rng = thread_rng();
35+
Self::with_ttl(
36+
access,
37+
Duration::from_millis(rng.gen_range((4 * 60 * 1000)..(5 * 60 * 1000))),
38+
)
39+
}
40+
pub fn with_ttl(access: Vec<UserStorageAccess>, ttl: Duration) -> Self {
3541
Self {
3642
access,
37-
valid_till: Instant::now()
38-
+ Duration::from_millis(rng.gen_range((4 * 60 * 1000)..(5 * 60 * 1000))),
43+
valid_till: Instant::now() + ttl,
3944
}
4045
}
4146

@@ -76,7 +81,14 @@ impl StorageMapping {
7681
} else {
7782
let users = self.load_storage_mapping(storage).await?;
7883

79-
self.cache.insert(storage, CachedAccess::new(users));
84+
self.cache.insert(
85+
storage,
86+
if storage == 1 {
87+
CachedAccess::with_ttl(users, Duration::from_secs(24 * 60 * 60))
88+
} else {
89+
CachedAccess::new(users)
90+
},
91+
);
8092
Ok(self.cache.get(&storage).unwrap())
8193
}
8294
}

0 commit comments

Comments
 (0)