Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

828 B
Raw Blame
use std::path::Path;

use litellm_cache::Error;

#[derive(Clone, Debug, PartialEq)]
pub enum StoredValue {
    Bytes(Vec<u8>),
    Text(String),
    Integer(i64),
    Float(f64),
    Pickle(Vec<u8>),
}

pub trait DiskStore: Send + Sync + 'static {
    fn directory(&self) -> &Path;
    fn get(&self, key: &str, now: f64) -> Result<Option<StoredValue>, Error>;
    fn set(
        &self,
        key: &str,
        value: StoredValue,
        expire_time: Option<f64>,
        now: f64,
    ) -> Result<(), Error>;
    fn pop(&self, key: &str, now: f64) -> Result<Option<StoredValue>, Error>;
    fn clear(&self) -> Result<(), Error>;
    fn update(
        &self,
        key: &str,
        now: f64,
        apply: &mut dyn FnMut(Option<StoredValue>) -> Result<(StoredValue, Option<f64>), Error>,
    ) -> Result<(), Error>;
}