pub struct GrantCache { /* private fields */ }Expand description
分片授权缓存 | Sharded grant cache
Implementations§
Source§impl GrantCache
impl GrantCache
Sourcepub fn new(ttl: Duration, max_entries: usize, single_flight: bool) -> Self
pub fn new(ttl: Duration, max_entries: usize, single_flight: bool) -> Self
构造缓存 | Construct the cache
Sourcepub fn from_config(config: &SaTokenConfig) -> Option<Arc<Self>>
pub fn from_config(config: &SaTokenConfig) -> Option<Arc<Self>>
依配置构造;返回 None 表示缓存关闭。
Build from config; None means the cache is off.
Sourcepub fn cache_key(kind: GrantKind, login_type: &str, login_id: &str) -> String
pub fn cache_key(kind: GrantKind, login_type: &str, login_id: &str) -> String
构造缓存键 | Build a cache key
Sourcepub async fn get_or_load<F, Fut>(
&self,
key: String,
loader: F,
) -> SaTokenResult<Arc<[String]>>
pub async fn get_or_load<F, Fut>( &self, key: String, loader: F, ) -> SaTokenResult<Arc<[String]>>
读取或加载 | Get or load
Sourcepub fn invalidate(&self, key: &str)
pub fn invalidate(&self, key: &str)
失效单个键 | Invalidate one key
Sourcepub fn invalidate_account(&self, login_type: &str, login_id: &str)
pub fn invalidate_account(&self, login_type: &str, login_id: &str)
失效某账号在某体系下的权限与角色两条缓存。 Invalidate both the permission and role entries of an account.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for GrantCache
impl !UnwindSafe for GrantCache
impl Freeze for GrantCache
impl Send for GrantCache
impl Sync for GrantCache
impl Unpin for GrantCache
impl UnsafeUnpin for GrantCache
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