pub struct CacheEntry<T> {
pub value: T,
pub expires_at: Instant,
pub current_time: Instant,
}Expand description
缓存条目信息,包含值和过期时间
Fields§
§value: T§expires_at: Instant§current_time: InstantImplementations§
Source§impl<T> CacheEntry<T>
impl<T> CacheEntry<T>
Sourcepub fn expiry_seconds(&self) -> u64
pub fn expiry_seconds(&self) -> u64
获取剩余的过期秒数
Sourcepub fn expires_within(&self, seconds: u64) -> bool
pub fn expires_within(&self, seconds: u64) -> bool
检查是否即将过期(剩余时间少于指定秒数)
Trait Implementations§
Source§impl<T: Clone> Clone for CacheEntry<T>
impl<T: Clone> Clone for CacheEntry<T>
Source§fn clone(&self) -> CacheEntry<T>
fn clone(&self) -> CacheEntry<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<T> Freeze for CacheEntry<T>where
T: Freeze,
impl<T> RefUnwindSafe for CacheEntry<T>where
T: RefUnwindSafe,
impl<T> Send for CacheEntry<T>where
T: Send,
impl<T> Sync for CacheEntry<T>where
T: Sync,
impl<T> Unpin for CacheEntry<T>where
T: Unpin,
impl<T> UnwindSafe for CacheEntry<T>where
T: 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