mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
implement clear_cache() for resolver service
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -7,7 +7,7 @@ use conduwuit::{
|
||||
utils::{math::Expected, rand, stream::TryIgnore},
|
||||
};
|
||||
use database::{Cbor, Deserialized, Map};
|
||||
use futures::{Stream, StreamExt};
|
||||
use futures::{Stream, StreamExt, future::join};
|
||||
use ruma::ServerName;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -45,6 +45,21 @@ impl Cache {
|
||||
}
|
||||
}
|
||||
|
||||
#[implement(Cache)]
|
||||
pub async fn clear(&self) { join(self.clear_destinations(), self.clear_overrides()).await; }
|
||||
|
||||
#[implement(Cache)]
|
||||
pub async fn clear_destinations(&self) { self.destinations.clear().await; }
|
||||
|
||||
#[implement(Cache)]
|
||||
pub async fn clear_overrides(&self) { self.overrides.clear().await; }
|
||||
|
||||
#[implement(Cache)]
|
||||
pub fn del_destination(&self, name: &ServerName) { self.destinations.remove(name); }
|
||||
|
||||
#[implement(Cache)]
|
||||
pub fn del_override(&self, name: &ServerName) { self.overrides.remove(name); }
|
||||
|
||||
#[implement(Cache)]
|
||||
pub fn set_destination(&self, name: &ServerName, dest: &CachedDest) {
|
||||
self.destinations.raw_put(name, Cbor(dest));
|
||||
|
||||
Reference in New Issue
Block a user