pub struct PoolBuilder { /* private fields */ }Expand description
Implementations§
Source§impl PoolBuilder
impl PoolBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Returns a new PoolBuilder with the default settings.
Sourcepub fn path<P: AsRef<Path>>(self, path: P) -> Self
pub fn path<P: AsRef<Path>>(self, path: P) -> Self
Specify the path of the sqlite3 database to open.
By default, an in-memory database is used.
Use a named shared in-memory sqlite database.
This opens connections with a URI of the form
file:<name>?mode=memory&cache=shared and enables
OpenFlags::SQLITE_OPEN_URI and
OpenFlags::SQLITE_OPEN_SHARED_CACHE.
SQLite shared-cache mode has caveats and is discouraged by SQLite for many workloads. Prefer a file-backed database when possible. The in-memory database is deleted after the last connection using this name is closed.
use async_sqlite::PoolBuilder;
let builder = PoolBuilder::new().shared_memory("my-pool").num_conns(2);Sourcepub fn flags(self, flags: OpenFlags) -> Self
pub fn flags(self, flags: OpenFlags) -> Self
Specify the OpenFlags to use when opening a new connection.
By default, OpenFlags::default() is used.
Sourcepub fn journal_mode(self, journal_mode: JournalMode) -> Self
pub fn journal_mode(self, journal_mode: JournalMode) -> Self
Specify the JournalMode to set when opening a new connection.
By default, no journal_mode is explicity set.
Sourcepub fn num_conns(self, num_conns: usize) -> Self
pub fn num_conns(self, num_conns: usize) -> Self
Specify the number of sqlite connections to open as part of the pool.
File-backed and shared-memory pools default to the number of logical
CPUs of the current system. Anonymous in-memory pools, including
path(":memory:"), default to 1 connection because each sqlite
:memory: connection is a separate database. Values less than 1 are
clamped to 1.
use async_sqlite::PoolBuilder;
let builder = PoolBuilder::new().num_conns(2);Sourcepub fn queue_capacity(self, queue_capacity: usize) -> Self
pub fn queue_capacity(self, queue_capacity: usize) -> Self
Limit the number of commands that may wait in each connection’s worker queue.
By default, each queue is unbounded. If a capacity is configured, calls
return Error::QueueFull when a selected connection already has that
many commands waiting for its worker thread. A capacity of 0 allows a
command to be accepted only when the worker is ready to receive it
immediately.
Trait Implementations§
Source§impl Clone for PoolBuilder
impl Clone for PoolBuilder
Source§fn clone(&self) -> PoolBuilder
fn clone(&self) -> PoolBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more