pub struct SqliteReadPool { /* private fields */ }Expand description
SQLite Read Connection Pool
Manages a pool of read-only SQLite connections for concurrent reads.
Each connection is opened with SQLITE_OPEN_READ_ONLY flag.
§Example
ⓘ
let pool = SqliteReadPool::new(&db_path, ReadPoolConfig::enabled(4))?;
// Acquire a pooled connection
let conn = pool.acquire().await?;
let count: i64 = conn.query_row("SELECT COUNT(*) FROM users", [], |row| row.get(0))?;
// Connection is returned to pool when `conn` is droppedImplementations§
Source§impl SqliteReadPool
impl SqliteReadPool
Sourcepub fn new(db_path: &Path, config: ReadPoolConfig) -> Result<Self>
pub fn new(db_path: &Path, config: ReadPoolConfig) -> Result<Self>
Create a new read pool with the given configuration
Opens pool_size read-only connections to the database.
Sourcepub async fn acquire(&self) -> Result<PooledSqliteConnection<'_>>
pub async fn acquire(&self) -> Result<PooledSqliteConnection<'_>>
Acquire a pooled read-only connection
Waits up to the configured timeout for a connection to become available. Returns an error if the timeout is exceeded.
Sourcepub fn try_acquire(&self) -> Result<Option<PooledSqliteConnection<'_>>>
pub fn try_acquire(&self) -> Result<Option<PooledSqliteConnection<'_>>>
Try to acquire a pooled read-only connection without waiting
Returns None if no connection is immediately available.
Sourcepub fn available_permits(&self) -> usize
pub fn available_permits(&self) -> usize
Get the number of available connections in the pool
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if pooling is enabled
Sourcepub fn acquire_blocking(&self) -> Result<PooledSqliteConnection<'_>>
pub fn acquire_blocking(&self) -> Result<PooledSqliteConnection<'_>>
Acquire a pooled read-only connection (blocking)
Blocks up to acquire_timeout waiting for an available connection.
Auto Trait Implementations§
impl !Freeze for SqliteReadPool
impl RefUnwindSafe for SqliteReadPool
impl Send for SqliteReadPool
impl Sync for SqliteReadPool
impl Unpin for SqliteReadPool
impl UnwindSafe for SqliteReadPool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more