pub struct TaskTtlConfig { /* private fields */ }Expand description
Per-task-type TTL configuration for result expiration
Allows setting different TTLs for different task types, with a fallback to a default TTL when no per-task override is configured.
§Example
use celers_backend_redis::TaskTtlConfig;
use std::time::Duration;
let mut config = TaskTtlConfig::with_default(Duration::from_secs(3600));
config.set_task_ttl("long_running_task", Duration::from_secs(86400));
config.set_task_ttl("ephemeral_task", Duration::from_secs(60));
assert_eq!(config.get_ttl("long_running_task"), Some(Duration::from_secs(86400)));
assert_eq!(config.get_ttl("unknown_task"), Some(Duration::from_secs(3600)));Implementations§
Source§impl TaskTtlConfig
impl TaskTtlConfig
Sourcepub fn new() -> TaskTtlConfig
pub fn new() -> TaskTtlConfig
Create a new empty TTL configuration (no default, no per-task overrides)
Sourcepub fn with_default(ttl: Duration) -> TaskTtlConfig
pub fn with_default(ttl: Duration) -> TaskTtlConfig
Create a TTL configuration with a default TTL for all tasks
Sourcepub fn set_task_ttl(&mut self, task_name: &str, ttl: Duration)
pub fn set_task_ttl(&mut self, task_name: &str, ttl: Duration)
Set a per-task-type TTL override
Sourcepub fn get_ttl(&self, task_name: &str) -> Option<Duration>
pub fn get_ttl(&self, task_name: &str) -> Option<Duration>
Get the TTL for a specific task type
Returns the per-task TTL if one is set, otherwise falls back to
the default TTL. Returns None if neither is configured.
Sourcepub fn default_ttl(&self) -> Option<Duration>
pub fn default_ttl(&self) -> Option<Duration>
Get the default TTL
Sourcepub fn set_default_ttl(&mut self, ttl: Duration)
pub fn set_default_ttl(&mut self, ttl: Duration)
Set the default TTL
Sourcepub fn remove_task_ttl(&mut self, task_name: &str) -> Option<Duration>
pub fn remove_task_ttl(&mut self, task_name: &str) -> Option<Duration>
Remove the per-task TTL override for a specific task type
Sourcepub fn task_ttl_count(&self) -> usize
pub fn task_ttl_count(&self) -> usize
Get the number of per-task TTL overrides
Trait Implementations§
Source§impl Clone for TaskTtlConfig
impl Clone for TaskTtlConfig
Source§fn clone(&self) -> TaskTtlConfig
fn clone(&self) -> TaskTtlConfig
Returns a duplicate of the value. Read more
1.0.0 · 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 TaskTtlConfig
impl Debug for TaskTtlConfig
Source§impl Default for TaskTtlConfig
impl Default for TaskTtlConfig
Source§fn default() -> TaskTtlConfig
fn default() -> TaskTtlConfig
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for TaskTtlConfig
impl RefUnwindSafe for TaskTtlConfig
impl Send for TaskTtlConfig
impl Sync for TaskTtlConfig
impl Unpin for TaskTtlConfig
impl UnsafeUnpin for TaskTtlConfig
impl UnwindSafe for TaskTtlConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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