pub struct CachePolicy {
pub key_func: Option<Arc<dyn Fn(&Value, &RunnableConfig) -> String + Send + Sync>>,
pub ttl: Option<Duration>,
pub max_entries: Option<usize>,
}Expand description
Cache policy controlling how node results are cached
Supports default (state-hash-based), TTL-based, and custom key function caching strategies.
Fields§
§key_func: Option<Arc<dyn Fn(&Value, &RunnableConfig) -> String + Send + Sync>>Optional custom key function for cache key generation
When set, this function computes the cache key from the current state value and execution config. When unset, the default state-hash-based key is used.
ttl: Option<Duration>Optional time-to-live for cached entries
max_entries: Option<usize>Optional maximum number of cache entries
Implementations§
Source§impl CachePolicy
impl CachePolicy
Sourcepub fn default_policy() -> Self
pub fn default_policy() -> Self
Create the default cache policy (state-hash-based, no TTL)
Sourcepub fn ttl(duration: Duration) -> Self
pub fn ttl(duration: Duration) -> Self
Create a TTL-based cache policy
Cached entries expire after the specified duration.
Sourcepub fn custom_key(
key_func: impl Fn(&Value, &RunnableConfig) -> String + Send + Sync + 'static,
) -> Self
pub fn custom_key( key_func: impl Fn(&Value, &RunnableConfig) -> String + Send + Sync + 'static, ) -> Self
Create a custom-key cache policy
Uses the provided function to compute cache keys instead of the default state-hash-based approach.
Trait Implementations§
Source§impl Clone for CachePolicy
impl Clone for CachePolicy
Source§fn clone(&self) -> CachePolicy
fn clone(&self) -> CachePolicy
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 moreSource§impl Debug for CachePolicy
impl Debug for CachePolicy
Auto Trait Implementations§
impl !RefUnwindSafe for CachePolicy
impl !UnwindSafe for CachePolicy
impl Freeze for CachePolicy
impl Send for CachePolicy
impl Sync for CachePolicy
impl Unpin for CachePolicy
impl UnsafeUnpin for CachePolicy
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