pub struct LruCacheShard<K: LruKey, T: LruValue> {
lru: Box<LruHandle<K, T>>,
low_priority_head: *mut LruHandle<K, T>,
high_priority_pool_capacity: usize,
high_priority_pool_usage: usize,
table: LruHandleTable<K, T>,
object_pool: Vec<Box<LruHandle<K, T>>>,
write_request: HashMap<K, Vec<Sender<CacheableEntry<K, T>>>>,
lru_usage: Arc<AtomicUsize>,
usage: Arc<AtomicUsize>,
capacity: usize,
}Fields§
§lru: Box<LruHandle<K, T>>The dummy header node of a ring linked list. The linked list is a LRU list, holding the cache handles that are not used externally. lru.prev point to the head of linked list while lru.next point to the tail of linked-list. Every time when the usage of cache reaches capacity we will remove lru.next at first.
low_priority_head: *mut LruHandle<K, T>§high_priority_pool_capacity: usize§high_priority_pool_usage: usize§table: LruHandleTable<K, T>§object_pool: Vec<Box<LruHandle<K, T>>>§write_request: HashMap<K, Vec<Sender<CacheableEntry<K, T>>>>§lru_usage: Arc<AtomicUsize>§usage: Arc<AtomicUsize>§capacity: usizeImplementations§
Source§impl<K: LruKey, T: LruValue> LruCacheShard<K, T>
impl<K: LruKey, T: LruValue> LruCacheShard<K, T>
fn new_with_priority_pool( capacity: usize, high_priority_ratio_percent: usize, ) -> Self
unsafe fn lru_remove(&mut self, e: *mut LruHandle<K, T>)
unsafe fn lru_insert(&mut self, e: *mut LruHandle<K, T>)
unsafe fn maintain_pool_size(&mut self)
unsafe fn evict_from_lru( &mut self, charge: usize, last_reference_list: &mut Vec<(K, T)>, )
Sourceunsafe fn clear_handle(&mut self, h: *mut LruHandle<K, T>) -> (K, T)
unsafe fn clear_handle(&mut self, h: *mut LruHandle<K, T>) -> (K, T)
Clear a currently used handle and recycle it if possible
Sourceunsafe fn try_recycle_handle_object(&mut self, h: *mut LruHandle<K, T>)
unsafe fn try_recycle_handle_object(&mut self, h: *mut LruHandle<K, T>)
Try to recycle a handle object if the object pool is not full.
The handle should already cleared its kv.
Sourceunsafe fn insert(
&mut self,
key: K,
hash: u64,
charge: usize,
value: T,
priority: CachePriority,
last_reference_list: &mut Vec<(K, T)>,
) -> *mut LruHandle<K, T>
unsafe fn insert( &mut self, key: K, hash: u64, charge: usize, value: T, priority: CachePriority, last_reference_list: &mut Vec<(K, T)>, ) -> *mut LruHandle<K, T>
insert a new key value in the cache. The handle for the new key value is returned.
Sourceunsafe fn release(&mut self, h: *mut LruHandle<K, T>) -> Option<(K, T)>
unsafe fn release(&mut self, h: *mut LruHandle<K, T>) -> Option<(K, T)>
Release the usage on a handle.
Return: Some(value) if the handle is released, and None if the value is still in use.
unsafe fn lookup(&mut self, hash: u64, key: &K) -> *mut LruHandle<K, T>
Sourceunsafe fn try_remove_cache_handle(
&mut self,
h: *mut LruHandle<K, T>,
) -> Option<(K, T)>
unsafe fn try_remove_cache_handle( &mut self, h: *mut LruHandle<K, T>, ) -> Option<(K, T)>
Try removing the handle from the cache if the handle is not used externally any more.
This method can only be called on the handle that just removed from the hash table.
unsafe fn clear(&mut self)
fn for_all<F>(&self, f: &mut F)
Trait Implementations§
impl<K: LruKey, T: LruValue> Send for LruCacheShard<K, T>
Auto Trait Implementations§
impl<K, T> Freeze for LruCacheShard<K, T>
impl<K, T> !RefUnwindSafe for LruCacheShard<K, T>
impl<K, T> !Sync for LruCacheShard<K, T>
impl<K, T> Unpin for LruCacheShard<K, T>where
K: Unpin,
impl<K, T> !UnwindSafe for LruCacheShard<K, T>
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
§impl<T> Downcast for Twhere
T: AsAny + ?Sized,
impl<T> Downcast for Twhere
T: AsAny + ?Sized,
§fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
Any.§fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
Any.§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = Infallible
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
Source§impl<M> MetricVecRelabelExt for M
impl<M> MetricVecRelabelExt for M
Source§fn relabel(
self,
metric_level: MetricLevel,
relabel_threshold: MetricLevel,
) -> RelabeledMetricVec<M>
fn relabel( self, metric_level: MetricLevel, relabel_threshold: MetricLevel, ) -> RelabeledMetricVec<M>
RelabeledMetricVec::with_metric_level.Source§fn relabel_n(
self,
metric_level: MetricLevel,
relabel_threshold: MetricLevel,
relabel_num: usize,
) -> RelabeledMetricVec<M>
fn relabel_n( self, metric_level: MetricLevel, relabel_threshold: MetricLevel, relabel_num: usize, ) -> RelabeledMetricVec<M>
RelabeledMetricVec::with_metric_level_relabel_n.Source§fn relabel_debug_1(
self,
relabel_threshold: MetricLevel,
) -> RelabeledMetricVec<M>
fn relabel_debug_1( self, relabel_threshold: MetricLevel, ) -> RelabeledMetricVec<M>
RelabeledMetricVec::with_metric_level_relabel_n with metric_level set to
MetricLevel::Debug and relabel_num set to 1.