pub struct CacheConfig {Show 13 fields
pub group_cache: CacheEntryConfig,
pub device_cache: CacheEntryConfig,
pub device_registry_cache: CacheEntryConfig,
pub lid_pn_cache: CacheEntryConfig,
pub retried_group_messages: CacheEntryConfig,
pub recent_messages: CacheEntryConfig,
pub message_retry_counts: CacheEntryConfig,
pub pdo_pending_requests: CacheEntryConfig,
pub session_locks_capacity: u64,
pub message_queues_capacity: u64,
pub message_enqueue_locks_capacity: u64,
pub sent_message_ttl_secs: u64,
pub cache_stores: CacheStores,
}Expand description
Configuration for all client caches and resource pools.
All fields default to WhatsApp Web behavior. Use ..Default::default() to
override only specific settings.
§Example — tune TTL/capacity
use whatsapp_rust::{CacheConfig, CacheEntryConfig};
use std::time::Duration;
let config = CacheConfig {
group_cache: CacheEntryConfig::new(None, 1_000), // no TTL
..Default::default()
};§Example — Redis for group and device caches only
use std::sync::Arc;
use whatsapp_rust::{CacheConfig, CacheStores};
let redis = Arc::new(MyRedisCacheStore::new("redis://localhost:6379"));
let config = CacheConfig {
cache_stores: CacheStores {
group_cache: Some(redis.clone()),
device_cache: Some(redis.clone()),
..Default::default()
},
..Default::default()
};Fields§
§group_cache: CacheEntryConfigGroup metadata cache (time_to_live). Default: 1h TTL, 250 entries.
device_cache: CacheEntryConfigDevice list cache (time_to_live). Default: 1h TTL, 5000 entries.
device_registry_cache: CacheEntryConfigDevice registry cache (time_to_live). Default: 1h TTL, 5000 entries.
lid_pn_cache: CacheEntryConfigLID-to-phone cache (time_to_idle). Default: 1h timeout, 10000 entries.
retried_group_messages: CacheEntryConfigRetried group messages tracker (time_to_live). Default: 5m TTL, 2000 entries.
recent_messages: CacheEntryConfigOptional L1 in-memory cache for sent messages (retry support). Default: capacity 0 (disabled — DB-only, matching WA Web). Set capacity > 0 to enable a fast in-memory cache in front of the DB.
message_retry_counts: CacheEntryConfigMessage retry counts (time_to_live). Default: 5m TTL, 1000 entries.
pdo_pending_requests: CacheEntryConfigPDO pending requests (time_to_live). Default: 30s TTL, 500 entries.
session_locks_capacity: u64Per-device Signal session lock capacity. Default: 2000.
message_queues_capacity: u64Per-chat message processing queue capacity. Default: 2000.
message_enqueue_locks_capacity: u64Per-chat message enqueue lock capacity. Default: 2000.
sent_message_ttl_secs: u64TTL in seconds for sent messages in DB before periodic cleanup. 0 = no automatic cleanup. Default: 300 (5 minutes).
cache_stores: CacheStoresPer-cache custom store overrides.
For each field set to Some(store), the corresponding cache uses that
backend instead of the default in-process moka cache. Fields left as
None keep the default moka behaviour.
Coordination caches (session_locks, message_queues,
message_enqueue_locks), the signal write-behind cache, and
pdo_pending_requests always stay in-process — they hold live Rust
objects (mutexes, channel senders, oneshot senders) that cannot be
serialised to an external store.
Trait Implementations§
Source§impl Clone for CacheConfig
impl Clone for CacheConfig
Source§fn clone(&self) -> CacheConfig
fn clone(&self) -> CacheConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CacheConfig
impl Debug for CacheConfig
Auto Trait Implementations§
impl Freeze for CacheConfig
impl !RefUnwindSafe for CacheConfig
impl Send for CacheConfig
impl Sync for CacheConfig
impl Unpin for CacheConfig
impl UnsafeUnpin for CacheConfig
impl !UnwindSafe for CacheConfig
Blanket Implementations§
Source§impl<T> AggregateExpressionMethods for T
impl<T> AggregateExpressionMethods for T
Source§fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
DISTINCT modifier for aggregate functions Read moreSource§fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
ALL modifier for aggregate functions Read moreSource§fn aggregate_filter<P>(self, f: P) -> Self::Output
fn aggregate_filter<P>(self, f: P) -> Self::Output
Source§fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
&self to an expression for Diesel’s query builder. Read more