Trait perseus::stores::mutable::MutableStore
source · pub trait MutableStore: Debug + Clone + Send + Sync {
// Required methods
fn read<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<String, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn write<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
name: &'life1 str,
content: &'life2 str
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
}
Expand description
A trait for implementations of stores that the Perseus engine can use for
mutable data, which may need to be altered while the server is running. In
exported apps, this is irrelevant, since there is no server process to speak
of. This store is used in particular by the revalidation and incremental
generation strategies, which will both update build artifacts for future
caching. By default, FsMutableStore
is used for simplicity and low
latency, though this is only viable in deployments with writable
filesystems. Notably, this precludes usage in serverless functions.
However, this is written deliberately as a trait with exposed, isolated
error types (see StoreError
), so that users can write their own
implementations of this. For instance, you could manage mutable artifacts in
a database, though this should be as low-latency as possible, since reads
and writes are required at extremely short-notice as new user requests
arrive.
Warning: the NotFound
error is integral to Perseus’ internal
operation, and must be returned if an asset does not exist. Do NOT return
any other error if everything else worked, but an asset simply did not
exist, or the entire render system will come crashing down around you!
Required Methods§
sourcefn read<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<String, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn read<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str ) -> Pin<Box<dyn Future<Output = Result<String, StoreError>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
Reads data from the named asset.
sourcefn write<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
name: &'life1 str,
content: &'life2 str
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn write<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, name: &'life1 str, content: &'life2 str ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,
Writes data to the named asset. This will create a new asset if one doesn’t exist already.