ETS-based prepared statement cache for ScyllaDB/Cassandra queries.
Caches prepared statements keyed by query hash to eliminate repeated query parsing overhead on ScyllaDB. This is especially impactful for high-throughput workloads where the same queries are executed repeatedly.
Usage
AshScylla.PreparedStatementCache.prepare(repo, "SELECT * FROM users WHERE id = ?")Starting the Cache
Add to your supervision tree:
children = [
AshScylla.PreparedStatementCache,
# ... other children
]Or start manually:
AshScylla.PreparedStatementCache.start_link([])
Summary
Functions
Returns a specification to start this module under a supervisor.
Clears all cached prepared statements.
Invalidates a specific cached statement by CQL string.
Prepares a CQL statement, using the cache if available.
Returns the number of cached statements.
Starts the prepared statement cache.
Returns the ETS table name for inspection/testing.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec clear() :: :ok
Clears all cached prepared statements.
@spec invalidate(String.t()) :: :ok
Invalidates a specific cached statement by CQL string.
Prepares a CQL statement, using the cache if available.
Returns {:ok, stmt} on success or {:error, reason} on failure.
@spec size() :: non_neg_integer()
Returns the number of cached statements.
@spec start_link(keyword()) :: GenServer.on_start()
Starts the prepared statement cache.
@spec table() :: atom()
Returns the ETS table name for inspection/testing.