pub struct StateCacheManager { /* private fields */ }Expand description
並行 State 特徴量キャッシュマネージャー。
xxHash3 による高速キー計算と、moka の TinyLFU/LRU 並行キャッシュにより、
複数スレッドからの同時参照をロックフリーに処理し、バイト重み付き退避を行う。
Implementations§
Source§impl StateCacheManager
impl StateCacheManager
Sourcepub fn new(
max_capacity_bytes: u64,
ttl_secs: u64,
compression_mode: CacheCompressionMode,
) -> Self
pub fn new( max_capacity_bytes: u64, ttl_secs: u64, compression_mode: CacheCompressionMode, ) -> Self
新規キャッシュマネージャーを初期化する。
§引数
max_capacity_bytes: 最大常駐メモリ容量(バイト数)。ttl_secs: エントリの有効期限(秒数)。compression_mode: キャッシュ圧縮モード。
Sourcepub fn compute_key(state_text: &str) -> u64
pub fn compute_key(state_text: &str) -> u64
State テキストから xxHash3 (64-bit) ハッシュキーを高速算出する。
AVX2、AVX-512、ARM NEON 命令により、8kトークンのテキストでも1μs未満で完了する。
§引数
state_text:State原文テキスト。
Sourcepub fn insert(&self, key: u64, features: Arc<CachedStateFeatures>)
pub fn insert(&self, key: u64, features: Arc<CachedStateFeatures>)
Sourcepub fn contains_key(&self, key: u64) -> bool
pub fn contains_key(&self, key: u64) -> bool
指定されたキーが存在するかを判定する。
Sourcepub fn invalidate(&self, key: u64)
pub fn invalidate(&self, key: u64)
指定されたキーのエントリを無効化(削除)する。
Sourcepub fn entry_count(&self) -> u64
pub fn entry_count(&self) -> u64
現在保持しているキャッシュエントリ数を取得する。
Sourcepub fn weighted_size(&self) -> u64
pub fn weighted_size(&self) -> u64
キャッシュ内の総メモリ占有バイト数を取得する。
Sourcepub fn compression_mode(&self) -> CacheCompressionMode
pub fn compression_mode(&self) -> CacheCompressionMode
設定されている圧縮モードを取得する。
Sourcepub fn run_pending_tasks(&self)
pub fn run_pending_tasks(&self)
保留中のキャッシュメンテナンスタスク(退避、カウント更新等)を直ちに同期実行する。
Auto Trait Implementations§
impl !RefUnwindSafe for StateCacheManager
impl !UnwindSafe for StateCacheManager
impl Freeze for StateCacheManager
impl Send for StateCacheManager
impl Sync for StateCacheManager
impl Unpin for StateCacheManager
impl UnsafeUnpin for StateCacheManager
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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