Skip to content

Commit

Permalink
fix: take only one value for expiration in config
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyrix126 committed Jul 10, 2024
1 parent e00466c commit 528847f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/cache.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::str::FromStr;
use std::time::Duration;

use axum::body::Bytes;
use derive_more::{Deref, DerefMut};
Expand All @@ -17,7 +18,7 @@ impl Cache {
Self(
MokaCache::builder()
.name("mnemosyne")
.time_to_idle(config.cache.expiration)
.time_to_idle(Duration::from_secs(config.cache.expiration))
.weigher(
|_key: &Uuid, (s, h, b): &(StatusCode, HeaderMap, Bytes)| -> u32 {
let s = s.to_string().get_size() as u32;
Expand Down
9 changes: 3 additions & 6 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use std::{
net::{Ipv4Addr, SocketAddr, SocketAddrV4},
time::Duration,
};
use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4};

use axum::http::{uri::PathAndQuery, HeaderValue};
use reqwest::Url;
Expand Down Expand Up @@ -58,7 +55,7 @@ impl Config {
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct CacheConfig {
/// cache expiration after last request
pub expiration: Duration,
pub expiration: u64,
/// in megabytes, the maximum size of memory the cache can take.
pub size_limit: u64,
}
Expand All @@ -68,7 +65,7 @@ pub struct CacheConfig {
impl Default for CacheConfig {
fn default() -> Self {
Self {
expiration: Duration::from_secs(2592000),
expiration: 2592000,
size_limit: 250,
}
}
Expand Down

0 comments on commit 528847f

Please sign in to comment.