pub struct CacheDb<D: Db> { /* private fields */ }
Implementations§
Source§impl<D: Db> CacheDb<D>
impl<D: Db> CacheDb<D>
Sourcepub fn new(db: D, watermark: usize) -> CacheDb<D>
pub fn new(db: D, watermark: usize) -> CacheDb<D>
Note that watermark
will still keep in the cache all objects still in use by the program.
So, setting watermark
to a value too low (eg. less than the size of objects actually in use by the
program) would make cache operation slow.
For this reason, if the cache used size reaches the watermark, then the watermark will be
automatically increased.
Trait Implementations§
Source§impl<D: ClientSideDb> ClientSideDb for CacheDb<D>
impl<D: ClientSideDb> ClientSideDb for CacheDb<D>
async fn storage_info(&self) -> Result<ClientStorageInfo>
async fn save_login(&self, info: LoginInfo) -> Result<()>
async fn get_saved_login(&self) -> Result<Option<LoginInfo>>
async fn remove_everything(&self) -> Result<()>
async fn get_json( &self, object_id: ObjectId, importance: Importance, ) -> Result<Value>
Source§async fn recreate<T: Object>(
&self,
object_id: ObjectId,
new_created_at: EventId,
object: Arc<T>,
updatedness: Option<Updatedness>,
additional_importance: Importance,
) -> Result<Option<Arc<T>>>
async fn recreate<T: Object>( &self, object_id: ObjectId, new_created_at: EventId, object: Arc<T>, updatedness: Option<Updatedness>, additional_importance: Importance, ) -> Result<Option<Arc<T>>>
Either create an object if it did not exist yet, or recreate it Read more
async fn client_query( &self, type_id: TypeId, query: Arc<Query>, ) -> Result<Vec<ObjectId>>
async fn remove(&self, object_id: ObjectId) -> Result<()>
async fn remove_event<T: Object>( &self, object_id: ObjectId, event_id: EventId, ) -> Result<()>
async fn set_object_importance( &self, object_id: ObjectId, new_importance: Importance, ) -> Result<()>
async fn set_importance_from_queries( &self, object_id: ObjectId, new_importance_from_queries: Importance, ) -> Result<()>
async fn client_vacuum( &self, notify_removals: impl 'static + CrdbSyncFn<ObjectId>, notify_query_removals: impl 'static + CrdbSyncFn<QueryId>, ) -> Result<()>
async fn list_uploads(&self) -> Result<Vec<UploadId>>
async fn get_upload(&self, upload_id: UploadId) -> Result<Option<Upload>>
async fn enqueue_upload( &self, upload: Upload, required_binaries: Vec<BinPtr>, ) -> Result<UploadId>
async fn upload_finished(&self, upload_id: UploadId) -> Result<()>
async fn get_saved_objects(&self) -> Result<HashMap<ObjectId, SavedObjectMeta>>
async fn get_saved_queries(&self) -> Result<HashMap<QueryId, SavedQuery>>
async fn record_query( &self, query_id: QueryId, query: Arc<Query>, type_id: TypeId, importance: Importance, ) -> Result<()>
async fn set_query_importance( &self, query_id: QueryId, importance: Importance, objects_matching_query: Vec<ObjectId>, ) -> Result<()>
async fn forget_query( &self, query_id: QueryId, objects_matching_query: Vec<ObjectId>, ) -> Result<()>
async fn update_queries( &self, queries: &HashSet<QueryId>, now_have_all_until: Updatedness, ) -> Result<()>
Source§impl<D: Db> Db for CacheDb<D>
impl<D: Db> Db for CacheDb<D>
Source§async fn reencode_old_versions<T: Object>(&self) -> usize
async fn reencode_old_versions<T: Object>(&self) -> usize
Returns the number of errors that happened while re-encoding
Source§async fn create<T: Object>(
&self,
object_id: ObjectId,
created_at: EventId,
object: Arc<T>,
updatedness: Option<Updatedness>,
importance: Importance,
) -> Result<Option<Arc<T>>>
async fn create<T: Object>( &self, object_id: ObjectId, created_at: EventId, object: Arc<T>, updatedness: Option<Updatedness>, importance: Importance, ) -> Result<Option<Arc<T>>>
Returns the new latest snapshot if it actually changed Read more
Source§async fn submit<T: Object>(
&self,
object_id: ObjectId,
event_id: EventId,
event: Arc<T::Event>,
updatedness: Option<Updatedness>,
additional_importance: Importance,
) -> Result<Option<Arc<T>>>
async fn submit<T: Object>( &self, object_id: ObjectId, event_id: EventId, event: Arc<T::Event>, updatedness: Option<Updatedness>, additional_importance: Importance, ) -> Result<Option<Arc<T>>>
Returns the new latest snapshot if it actually changed Read more
async fn get_latest<T: Object>( &self, object_id: ObjectId, importance: Importance, ) -> Result<Arc<T>>
async fn create_binary(&self, binary_id: BinPtr, data: Arc<[u8]>) -> Result<()>
async fn get_binary(&self, binary_id: BinPtr) -> Result<Option<Arc<[u8]>>>
async fn assert_invariants_generic(&self)
async fn assert_invariants_for<T: Object>(&self)
Source§impl<D: ServerSideDb> ServerSideDb for CacheDb<D>
impl<D: ServerSideDb> ServerSideDb for CacheDb<D>
type Connection = <D as ServerSideDb>::Connection
type Transaction<'a> = <D as ServerSideDb>::Transaction<'a>
type Lock<'a> = <D as ServerSideDb>::Lock<'a>
fn get_users_who_can_read<'a, 'ret: 'a, T: Object, C: CanDoCallbacks>( &'ret self, object_id: ObjectId, object: &'a T, cb: &'a C, ) -> Pin<Box<dyn Future<Output = Result<UsersWhoCanRead<Self::Lock<'ret>>>> + 'a>>
async fn get_transaction(&self) -> Result<Self::Transaction<'_>>
async fn get_latest_snapshot( &self, transaction: &mut Self::Connection, user: User, object_id: ObjectId, ) -> Result<Arc<Value>>
async fn get_all( &self, connection: &mut Self::Connection, user: User, object_id: ObjectId, only_updated_since: Option<Updatedness>, ) -> Result<ObjectData>
async fn server_query( &self, user: User, type_id: TypeId, only_updated_since: Option<Updatedness>, query: Arc<Query>, ) -> Result<Vec<ObjectId>>
Source§async fn server_vacuum(
&self,
no_new_changes_before: Option<EventId>,
updatedness: Updatedness,
kill_sessions_older_than: Option<SystemTime>,
notify_recreation: impl FnMut(Update, HashSet<User>),
) -> Result<()>
async fn server_vacuum( &self, no_new_changes_before: Option<EventId>, updatedness: Updatedness, kill_sessions_older_than: Option<SystemTime>, notify_recreation: impl FnMut(Update, HashSet<User>), ) -> Result<()>
Cleans up and optimizes up the database Read more
Source§async fn recreate_at<'a, T: Object, C: CanDoCallbacks>(
&'a self,
object_id: ObjectId,
event_id: EventId,
updatedness: Updatedness,
cb: &'a C,
) -> Result<Option<(EventId, Arc<T>)>>
async fn recreate_at<'a, T: Object, C: CanDoCallbacks>( &'a self, object_id: ObjectId, event_id: EventId, updatedness: Updatedness, cb: &'a C, ) -> Result<Option<(EventId, Arc<T>)>>
This function assumes that the lock on
object_id
is already taken Read moreasync fn create_and_return_rdep_changes<T: Object>( &self, object_id: ObjectId, created_at: EventId, object: Arc<T>, updatedness: Updatedness, ) -> Result<Option<(Arc<T>, Vec<ReadPermsChanges>)>>
async fn submit_and_return_rdep_changes<T: Object>( &self, object_id: ObjectId, event_id: EventId, event: Arc<T::Event>, updatedness: Updatedness, ) -> Result<Option<(Arc<T>, Vec<ReadPermsChanges>)>>
async fn update_pending_rdeps(&self) -> Result<()>
async fn login_session( &self, session: Session, ) -> Result<(SessionToken, SessionRef)>
async fn resume_session(&self, token: SessionToken) -> Result<Session>
async fn mark_session_active( &self, token: SessionToken, at: SystemTime, ) -> Result<()>
async fn rename_session<'a>( &'a self, token: SessionToken, new_name: &'a str, ) -> Result<()>
async fn list_sessions(&self, user: User) -> Result<Vec<Session>>
async fn disconnect_session( &self, user: User, session: SessionRef, ) -> Result<()>
Auto Trait Implementations§
impl<D> Freeze for CacheDb<D>where
D: Freeze,
impl<D> RefUnwindSafe for CacheDb<D>where
D: RefUnwindSafe,
impl<D> Send for CacheDb<D>
impl<D> Sync for CacheDb<D>
impl<D> Unpin for CacheDb<D>where
D: Unpin,
impl<D> UnwindSafe for CacheDb<D>where
D: UnwindSafe,
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