1use std::collections::{BTreeMap, BTreeSet, HashMap, VecDeque};
2
3use bincode::{Decode, Encode};
4
5use crate::utils;
6
7#[derive(Debug, Clone, Encode, Decode)]
8pub enum Value {
9 String(String),
10 List(VecDeque<String>), Hash(HashMap<String, String>), Set(BTreeSet<String>), SortedSet(BTreeMap<String, f64>), }
15
16#[derive(Debug, Clone, Encode, Decode)]
17pub struct Entry {
18 pub value: Value,
19 pub expires_at: Option<u64>,
20}
21
22impl Entry {
23 pub fn is_expired(&self) -> bool {
24 let now = utils::get_unix_timestamp();
25 self.expires_at.map(|t| t <= now).unwrap_or(false)
26 }
27}