pub struct PromptCache { /* private fields */ }Expand description
A cache for system prompt strings keyed by PromptCacheKey.
§Examples
use vlorql_core::cache::PromptCache;
let cache = PromptCache::new(100, 300);
assert_eq!(cache.size(), 0);Implementations§
Source§impl PromptCache
impl PromptCache
Sourcepub fn new(capacity: u64, ttl_seconds: u64) -> Self
pub fn new(capacity: u64, ttl_seconds: u64) -> Self
Creates a new prompt cache.
capacity— maximum number of entries before the cache evicts least-recently-used items.ttl_seconds— time-to-live in seconds. Entries older than this are automatically invalidated.
Sourcepub async fn get(&self, key: &PromptCacheKey) -> Option<String>
pub async fn get(&self, key: &PromptCacheKey) -> Option<String>
Returns the cached prompt for key, or None on a miss.
Sourcepub async fn insert(&self, key: PromptCacheKey, prompt: String)
pub async fn insert(&self, key: PromptCacheKey, prompt: String)
Inserts a prompt string into the cache.
Sourcepub async fn invalidate(&self, key: &PromptCacheKey)
pub async fn invalidate(&self, key: &PromptCacheKey)
Removes the entry for key from the cache.
Trait Implementations§
Source§impl Clone for PromptCache
impl Clone for PromptCache
Source§fn clone(&self) -> PromptCache
fn clone(&self) -> PromptCache
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 !RefUnwindSafe for PromptCache
impl !UnwindSafe for PromptCache
impl Freeze for PromptCache
impl Send for PromptCache
impl Sync for PromptCache
impl Unpin for PromptCache
impl UnsafeUnpin for PromptCache
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request