Module statement_cache

Module statement_cache 

Source
Expand description

Prepared statement caching with LRU eviction.

This module provides automatic caching of prepared statements to improve performance for repeated query execution. The cache uses an LRU (Least Recently Used) eviction policy to manage memory and server-side resources.

§Lifecycle

  1. First execution of a parameterized query calls sp_prepare, returning a handle
  2. The handle is cached by SQL hash; subsequent executions use sp_execute
  3. When the cache is full, LRU eviction calls sp_unprepare for evicted handles
  4. Pool reset (sp_reset_connection) invalidates all handles, clearing the cache
  5. Connection close implicitly releases all server-side handles

Structs§

PreparedStatement
A cached prepared statement.
StatementCache
LRU cache for prepared statements.
StatementCacheConfig
Configuration for statement caching.

Constants§

DEFAULT_MAX_STATEMENTS
Default maximum number of prepared statements to cache per connection.

Functions§

hash_sql
Hash SQL text for cache lookup.