sqlitex v1.6.0 Sqlitex.Server.StatementCache View Source

Implements a least-recently used (LRU) cache for prepared SQLite statements.

Caches a fixed number of prepared statements and purges the statements which were least-recently used when that limit is exceeded.

Link to this section Summary

Functions

Creates a new prepared statement cache.

Given a statement cache and an SQL statement (string), returns a tuple containing the updated statement cache and a prepared SQL statement.

Link to this section Functions

Creates a new prepared statement cache.

Link to this function

prepare(cache, sql, opts \\ []) View Source

Given a statement cache and an SQL statement (string), returns a tuple containing the updated statement cache and a prepared SQL statement.

If possible, reuses an existing prepared statement. If not, prepares the statement and adds it to the cache, possibly removing the least-recently used prepared statement if the designated cache size limit would be exceeded.

Will return {:error, reason} if SQLite is unable to prepare the statement.