Struct akd::storage::manager::StorageManager
source · pub struct StorageManager<Db: Database> {
pub db: Db,
/* private fields */
}
Expand description
Represents the manager of the storage mediums, including caching and transactional operations (creating the transaction, committing it, etc)
Fields§
§db: Db
The underlying database managed by this storage manager
Implementations§
source§impl<Db: Database> StorageManager<Db>
impl<Db: Database> StorageManager<Db>
sourcepub fn new_no_cache(db: Db) -> Self
pub fn new_no_cache(db: Db) -> Self
Create a new storage manager with NO CACHE
sourcepub fn new(
db: Db,
cache_item_lifetime: Option<Duration>,
cache_limit_bytes: Option<usize>,
cache_clean_frequency: Option<Duration>
) -> Self
pub fn new(
db: Db,
cache_item_lifetime: Option<Duration>,
cache_limit_bytes: Option<usize>,
cache_clean_frequency: Option<Duration>
) -> Self
Create a new storage manager with a cache utilizing the options provided (or defaults)
sourcepub async fn log_metrics(&self, level: Level)
pub async fn log_metrics(&self, level: Level)
Log metrics from the storage manager (cache, transaction, and storage hit rates etc)
sourcepub fn begin_transaction(&self) -> bool
pub fn begin_transaction(&self) -> bool
Start an in-memory transaction of changes
sourcepub async fn commit_transaction(&self) -> Result<(), StorageError>
pub async fn commit_transaction(&self) -> Result<(), StorageError>
Commit a transaction in the database
sourcepub fn rollback_transaction(&self) -> Result<(), StorageError>
pub fn rollback_transaction(&self) -> Result<(), StorageError>
Rollback a transaction
sourcepub fn is_transaction_active(&self) -> bool
pub fn is_transaction_active(&self) -> bool
Retrieve a flag determining if there is a transaction active
sourcepub async fn set(&self, record: DbRecord) -> Result<(), StorageError>
pub async fn set(&self, record: DbRecord) -> Result<(), StorageError>
Store a record in the database
sourcepub async fn batch_set(&self, records: Vec<DbRecord>) -> Result<(), StorageError>
pub async fn batch_set(&self, records: Vec<DbRecord>) -> Result<(), StorageError>
Set a batch of records in the database
sourcepub async fn get_direct<St: Storable>(
&self,
id: &St::StorageKey
) -> Result<DbRecord, StorageError>
pub async fn get_direct<St: Storable>(
&self,
id: &St::StorageKey
) -> Result<DbRecord, StorageError>
Retrieve a stored record directly from the data layer, ignoring any caching or transaction processes
sourcepub async fn get<St: Storable>(
&self,
id: &St::StorageKey
) -> Result<DbRecord, StorageError>
pub async fn get<St: Storable>(
&self,
id: &St::StorageKey
) -> Result<DbRecord, StorageError>
Retrieve a stored record from the database
sourcepub async fn batch_get<St: Storable>(
&self,
ids: &[St::StorageKey]
) -> Result<Vec<DbRecord>, StorageError>
pub async fn batch_get<St: Storable>(
&self,
ids: &[St::StorageKey]
) -> Result<Vec<DbRecord>, StorageError>
Retrieve a batch of records by id from the database
sourcepub async fn flush_cache(&self)
pub async fn flush_cache(&self)
Flush the caching of objects (if present)
sourcepub async fn tombstone_value_states(
&self,
keys: &[ValueStateKey]
) -> Result<(), StorageError>
pub async fn tombstone_value_states(
&self,
keys: &[ValueStateKey]
) -> Result<(), StorageError>
Tombstone a set of records adhereing to the caching + transactional settings of the storage manager
sourcepub async fn get_user_state(
&self,
username: &AkdLabel,
flag: ValueStateRetrievalFlag
) -> Result<ValueState, StorageError>
pub async fn get_user_state(
&self,
username: &AkdLabel,
flag: ValueStateRetrievalFlag
) -> Result<ValueState, StorageError>
Retrieve the specified user state object based on the retrieval flag from the database
sourcepub async fn get_user_data(
&self,
username: &AkdLabel
) -> Result<KeyData, StorageError>
pub async fn get_user_data(
&self,
username: &AkdLabel
) -> Result<KeyData, StorageError>
Retrieve all values states for a given user
sourcepub async fn get_user_state_versions(
&self,
usernames: &[AkdLabel],
flag: ValueStateRetrievalFlag
) -> Result<HashMap<AkdLabel, (u64, AkdValue)>, StorageError>
pub async fn get_user_state_versions(
&self,
usernames: &[AkdLabel],
flag: ValueStateRetrievalFlag
) -> Result<HashMap<AkdLabel, (u64, AkdValue)>, StorageError>
Retrieve the user -> state version mapping in bulk. This is the same as get_user_state in a loop, but with less data retrieved from the storage layer
Trait Implementations§
source§impl<Db: Clone + Database> Clone for StorageManager<Db>
impl<Db: Clone + Database> Clone for StorageManager<Db>
source§fn clone(&self) -> StorageManager<Db>
fn clone(&self) -> StorageManager<Db>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more