pub struct DeptTreeCache { /* private fields */ }Expand description
部门树缓存
Implementations§
Source§impl DeptTreeCache
impl DeptTreeCache
Sourcepub fn new(provider: Arc<dyn DeptTreeProvider>, ttl: Duration) -> Self
pub fn new(provider: Arc<dyn DeptTreeProvider>, ttl: Duration) -> Self
创建缓存
Sourcepub async fn get_with_sub(
&self,
dept_id: i64,
) -> Result<Vec<i64>, DataScopeError>
pub async fn get_with_sub( &self, dept_id: i64, ) -> Result<Vec<i64>, DataScopeError>
获取指定部门及其所有子部门 ID 列表(含自身)
缓存命中(键存在且未过期)直接返回;未命中调用 provider 递归展开。
Sourcepub fn invalidate(&self, dept_id: i64)
pub fn invalidate(&self, dept_id: i64)
失效单键
Sourcepub fn invalidate_all(&self)
pub fn invalidate_all(&self)
全量失效
Auto Trait Implementations§
impl !RefUnwindSafe for DeptTreeCache
impl !UnwindSafe for DeptTreeCache
impl Freeze for DeptTreeCache
impl Send for DeptTreeCache
impl Sync for DeptTreeCache
impl Unpin for DeptTreeCache
impl UnsafeUnpin for DeptTreeCache
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more