pub struct Scratchpad { /* private fields */ }Expand description
An ephemeral key-value scratchpad with TTL-based expiry. Designed for agent workflows that need temporary memory between steps.
Implementations§
Source§impl Scratchpad
impl Scratchpad
Sourcepub fn set(&mut self, key: &str, value: &str) -> Result<(), ScratchpadError>
pub fn set(&mut self, key: &str, value: &str) -> Result<(), ScratchpadError>
Set a key-value pair with the default TTL.
Sourcepub fn set_with_ttl(
&mut self,
key: &str,
value: &str,
ttl: u32,
) -> Result<(), ScratchpadError>
pub fn set_with_ttl( &mut self, key: &str, value: &str, ttl: u32, ) -> Result<(), ScratchpadError>
Set a key-value pair with a custom TTL.
Sourcepub fn get(&self, key: &str) -> Option<&str>
pub fn get(&self, key: &str) -> Option<&str>
Get a value by key. Returns None if the key doesn’t exist or is expired.
Sourcepub fn current_tick(&self) -> u32
pub fn current_tick(&self) -> u32
Get the current tick.
Sourcepub fn evict_expired(&mut self) -> usize
pub fn evict_expired(&mut self) -> usize
Evict all expired entries immediately.
Auto Trait Implementations§
impl Freeze for Scratchpad
impl RefUnwindSafe for Scratchpad
impl Send for Scratchpad
impl Sync for Scratchpad
impl Unpin for Scratchpad
impl UnsafeUnpin for Scratchpad
impl UnwindSafe for Scratchpad
Blanket Implementations§
§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
Aggregate shares in an MPC protocol.
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