use std::collections::HashMap;
use async_trait::async_trait;
use crate::typing::Dict as normal_dict;
use itertools::Itertools;
const MINUTE: f32 = 60f32;
const HOUR: f32 = MINUTE * 60.;
const DAY: f32 = HOUR * 24.;
const WEEK: f32 = DAY * 7.;
type Dict = HashMap<i64, (i64, reqwest::Response)>;
#[derive(Debug)]
pub(crate) struct CacheKey;
impl CacheKey {
}
#[derive(Debug)]
pub(crate) struct Cache {
pub(crate) cache: Dict,
pub(crate) maxsize: usize,
pub(crate) ttl: f32,
pub(crate) static_ttl: f32,
}
impl Cache {
pub(crate) fn new(maxsize: Option<usize>, ttl: Option<f32>, static_ttl: Option<f32>) -> Self {
Self {
cache: HashMap::new(),
maxsize: maxsize.unwrap_or(1024),
ttl: ttl.unwrap_or(HOUR),
static_ttl: static_ttl.unwrap_or(DAY),
}
}
pub(crate) fn static_new(ttl: Option<f32>) -> Self {
Self {
cache: Default::default(),
maxsize: u32::MAX as usize,
ttl: 0f32,
static_ttl: ttl.unwrap_or(DAY),
}
}
pub(crate) fn len(&self) -> usize {
self.cache.len()
}
async fn get_static(&self, key: &str) -> Option<reqwest::Response> {
todo!()
}
async fn set_static(&self, key: &str, value: reqwest::Response) {
todo!()
}
}