LemonAi.ModelCache (lemon_ai v0.1.0)

View Source

Caches model availability per provider using ETS to reduce redundant API calls. Ported from Oh-My-Pi's model-cache.ts (SQLite) to idiomatic Elixir with ETS.

Summary

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

invalidate(provider_id)

@spec invalidate(term()) :: :ok

invalidate_all()

@spec invalidate_all() :: :ok

read(provider_id, ttl_ms \\ 300_000)

@spec read(term(), non_neg_integer()) ::
  {:ok,
   %{
     models: list(),
     fresh: boolean(),
     authoritative: boolean(),
     updated_at: integer()
   }}
  | :miss

start_link(opts \\ [])

stats()

@spec stats() :: %{entries: non_neg_integer(), providers: list()}

write(provider_id, models, opts \\ [])

@spec write(term(), list(), keyword()) :: :ok