LemonCore.Store.SqliteBackend (lemon_core v0.1.0)

View Source

SQLite-backed storage backend with optional ephemeral tables.

Most tables are persisted in a single SQLite database. High-churn tables (like :runs) can be configured as ephemeral to avoid disk write amplification. Ephemeral tables are stored in ETS only.

Options

  • :path - Required. Path to SQLite file, or a directory (then store.sqlite3 is used)
  • :ephemeral_tables - Optional list of table atoms to keep in ETS (default: [:runs])

Summary

Functions

Closes prepared statements and SQLite connection.

Lists the most recent limit entries from table, ordered by updated_at_ms DESC.

Returns all table names currently present.

Functions

close(arg1)

@spec close(map()) :: :ok

Closes prepared statements and SQLite connection.

list_recent(state, table, limit)

@spec list_recent(map(), atom(), pos_integer()) ::
  {:ok, [{term(), term()}], map()} | {:error, term()}

Lists the most recent limit entries from table, ordered by updated_at_ms DESC.

This pushes the ORDER BY + LIMIT into SQLite so the GenServer does not need to load every row into memory. Ephemeral (ETS-backed) tables fall back to loading all rows and sorting in Elixir.

Returns {:ok, [{key, value}], state}.

list_tables(state)

@spec list_tables(map()) :: [atom()]

Returns all table names currently present.