添加授权缓存

This commit is contained in:
李运家 2024-04-17 08:50:28 +08:00
parent 776d81cda2
commit 4f58c3e3e6
3 changed files with 22 additions and 4 deletions

View File

@ -0,0 +1,17 @@
use std::sync::OnceLock;
use moka::future::Cache;
#[macro_export]
macro_rules! auth_cache {
() => {
library::core::auth_cache::init_auth_cache()
};
}
static AUTH_CACHE: OnceLock<Cache<String, String>> = OnceLock::new();
fn init_auth_cache() -> &'static Cache<String, String> {
AUTH_CACHE.get_or_init(|| {
Cache::new(1000)
})
}

View File

@ -1,7 +1,7 @@
use std::collections::HashMap;
use moka::future::Cache;
// use std::collections::HashMap;
// use moka::future::Cache;
//
//
// use std::any::{Any, TypeId};
// use std::collections::HashMap;
// use std::lazy::SyncLazy;

View File

@ -2,3 +2,4 @@ pub mod config;
pub mod logger;
pub mod db;
pub mod local_cache;
pub mod auth_cache;