aboutsummaryrefslogtreecommitdiff
path: root/src/route.rs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-04-18 04:17:35 -0700
committerFuwn <[email protected]>2022-04-18 04:17:35 -0700
commit78f3a233ca24d4df123f2da35897f3e5eec50fc8 (patch)
tree28a5002625a1da57c86bdb6f6980419f0469166e /src/route.rs
parentfeat: cache more dynamic routes (diff)
downloadlocus-78f3a233ca24d4df123f2da35897f3e5eec50fc8.tar.xz
locus-78f3a233ca24d4df123f2da35897f3e5eec50fc8.zip
refactor: constify many constants
Diffstat (limited to 'src/route.rs')
-rw-r--r--src/route.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/route.rs b/src/route.rs
index 7dfa5e7..7140e52 100644
--- a/src/route.rs
+++ b/src/route.rs
@@ -22,6 +22,8 @@ use tokio::time::Instant;
use crate::ROUTES;
+pub const CACHE_RATE: u64 = 60 * 5;
+
#[derive(Debug)]
pub struct Route {
pub description: String,
@@ -62,7 +64,7 @@ pub fn cache(context: &windmark::returnable::RouteContext<'_>, response: &str) {
SyncLazy::new(|| Mutex::new(Instant::now()));
if (*LAST_CACHED.lock().unwrap()).elapsed()
- >= std::time::Duration::from_secs(crate::CACHE_RATE)
+ >= std::time::Duration::from_secs(CACHE_RATE)
|| (*ROUTES.lock().unwrap())
.get(context.url.path())
.is_some_and(|&r| r.text_cache.is_empty())