fbc_starter/cache/
cache_key.rs1use serde::{Deserialize, Serialize};
2use std::time::Duration;
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
6pub enum ValueType {
7 Obj,
9 String,
11 Number,
13}
14
15impl ValueType {
16 pub fn as_str(&self) -> &'static str {
17 match self {
18 ValueType::Obj => "obj",
19 ValueType::String => "string",
20 ValueType::Number => "number",
21 }
22 }
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27pub struct CacheKey {
28 pub key: String,
29 pub expire: Option<Duration>,
30}
31
32impl CacheKey {
33 pub fn new(key: String, expire: Option<Duration>) -> Self {
34 Self { key, expire }
35 }
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize)]
40pub struct CacheHashKey {
41 pub key: String,
42 pub field: Option<String>,
43 pub expire: Option<Duration>,
44}
45
46impl CacheHashKey {
47 pub fn new(key: String, field: Option<String>, expire: Option<Duration>) -> Self {
48 Self { key, field, expire }
49 }
50}