use serde::{Deserialize, Serialize};
use std::time::Duration;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum ValueType {
Obj,
String,
Number,
}
impl ValueType {
pub fn as_str(&self) -> &'static str {
match self {
ValueType::Obj => "obj",
ValueType::String => "string",
ValueType::Number => "number",
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CacheKey {
pub key: String,
pub expire: Option<Duration>,
}
impl CacheKey {
pub fn new(key: String, expire: Option<Duration>) -> Self {
Self { key, expire }
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CacheHashKey {
pub key: String,
pub field: Option<String>,
pub expire: Option<Duration>,
}
impl CacheHashKey {
pub fn new(key: String, field: Option<String>, expire: Option<Duration>) -> Self {
Self { key, field, expire }
}
}