Skip to main content

cubecl_environment/persistence/
mod.rs

1//! Key-value persistence.
2//!
3//! A [`Store`] is a typed in-memory map that syncs its content to an optional
4//! [`Storage`]: an embedded Turso database (feature `persistence`) on a file
5//! system natively and on OPFS in the browser, or nothing at all.
6//! [`CacheOption`] decides whether the whole namespace is ingested at open or
7//! entries are faulted in one key at a time.
8//!
9//! Every cache is identified by a [`Namespace`], a `/`-separated string such
10//! as `autotune/0.11.0/cuda-0/matmul`. All the namespaces of an environment
11//! share one database file and are told apart by a column rather than by a
12//! directory tree. Entries are therefore looked up per key, several processes
13//! can share a root safely through WAL, and shipping a subset of them is a
14//! query away (see [`crate::bundle`]).
15
16/// The writable half of persistence: where a namespace's entries live.
17pub mod storage;
18
19pub use storage::*;
20
21mod namespace;
22mod store;
23
24pub use namespace::Namespace;
25pub use store::*;
26
27/// Turso persistence: the database file shared by every namespace of an
28/// environment.
29#[cfg(any(native_cache, browser_cache))]
30pub(crate) mod turso;
31
32#[cfg(any(native_cache, browser_cache))]
33pub use turso::{Access, Database, TursoStorage};
34
35#[cfg(browser_cache)]
36mod turso_browser;
37
38/// Cache root location selection.
39///
40/// Available wherever there is a file system, not only when the Turso
41/// backend is compiled in: the root is what names an environment on disk, and
42/// [`crate::environment`] exposes it independently of how entries are stored.
43#[cfg(std_io)]
44mod root;
45
46#[cfg(std_io)]
47pub use root::CacheConfig;