1123Javayanglei/new-api-vision-proxy/cache does not have a README file

    CaptionStore

    pub struct CaptionStore {
    // private fields
    }

    Persistent, O(1) in-memory caption store backed by an async 2-segment rotating append-only disk log (captions.0.log / captions.1.log) and zero-lock @cond_var concurrent in-flight deduplication.

    CaptionStore::begin_lookup

    fn CaptionStore::begin_lookup(self : CaptionStore, key : String, now_sec? : Int64) -> LookupOutcome

    Probe cache for key, or register/join an in-flight request slot so concurrent identical data: images share a single upstream vision call.

    CaptionStore::close

    async fn CaptionStore::close(self : CaptionStore) -> Unit

    Flush pending records and close the underlying segment file handle.

    CaptionStore::finish_lookup

    fn CaptionStore::finish_lookup(self : CaptionStore, key : String, slot : PendingSlot, result : Result[String, VisionFailure], now_sec? : Int64) -> Unit

    Complete an Owner slot, storing caption on Ok and waking all waiters.

    CaptionStore::flush_pending

    async fn CaptionStore::flush_pending(self : CaptionStore) -> Unit

    Flush queued cache writes to the active segment off the event loop.

    CaptionStore::get

    fn CaptionStore::get(self : CaptionStore, key : String, now_sec? : Int64) -> String?

    O(1) cache lookup without in-flight registration (useful for tests).

    CaptionStore::is_persistent

    fn CaptionStore::is_persistent(self : CaptionStore) -> Bool

    CaptionStore::memory

    fn CaptionStore::memory(ttl_sec? : Int64, max_entries? : Int) -> CaptionStore

    Pure in-memory store (used for --no-cache and unit tests).

    CaptionStore::open

    async fn CaptionStore::open(dir : String, ttl_sec? : Int64, max_entries? : Int, worker_id? : Int, workers? : Int, now_sec? : Int64) -> CaptionStore

    Open a persistent CaptionStore in dir, replaying existing segment logs and recovering cleanly from any truncated tail. Falls back to memory mode if dir is unwritable.

    CaptionStore::put

    fn CaptionStore::put(self : CaptionStore, key : String, caption : String, now_sec? : Int64) -> Unit

    Insert or update a caption directly in memory and queue async persistence.

    CaptionStore::run_flusher

    async fn CaptionStore::run_flusher(self : CaptionStore) -> Unit

    Background flusher loop: coalesces disk writes every ~200ms off the hot path.

    CaptionStore::size

    fn CaptionStore::size(self : CaptionStore) -> Int

    CaptionStore::stats

    fn CaptionStore::stats(self : CaptionStore) -> (Int, Int64, Int64, Int64)

    LookupOutcome

    pub(all) enum LookupOutcome {
    Hit(String)
    Wait(PendingSlot)
    Owner(PendingSlot)
    }

    Result of probing the caption store before calling the vision model.

    PendingSlot

    pub struct PendingSlot {
    // private fields
    }

    Shared slot for coalescing concurrent requests for the same inline image.

    PendingSlot::wait

    async fn PendingSlot::wait(self : PendingSlot) -> Result[String, VisionFailure]

    Wait until the owner fiber finishes captioning this image.

    VisionFailure

    pub(all) struct VisionFailure {
    status : Int
    body : Bytes
    headers : Array[(String, String)]
    }

    Upstream error or invalid caption returned during the vision stage.

    now_unix_sec

    fn now_unix_sec() -> Int64

    Source Files