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
- First execution of a parameterized query calls
sp_prepare, returning a handle - The handle is cached by SQL hash; subsequent executions use
sp_execute - When the cache is full, LRU eviction calls
sp_unpreparefor evicted handles - Pool reset (
sp_reset_connection) invalidates all handles, clearing the cache - Connection close implicitly releases all server-side handles
Structs§
- Prepared
Statement - A cached prepared statement.
- Statement
Cache - LRU cache for prepared statements.
- Statement
Cache Config - 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.