pub struct CacheConfig {
pub group_cache: CacheEntryConfig,
pub device_registry_cache: CacheEntryConfig,
pub lid_pn_cache: CacheEntryConfig,
pub recent_messages: CacheEntryConfig,
pub message_retry_counts: CacheEntryConfig,
pub undecryptable_dispatched: CacheEntryConfig,
pub pdo_pending_requests: CacheEntryConfig,
pub sender_key_devices_cache: CacheEntryConfig,
pub session_locks_capacity: u64,
pub chat_lanes_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 registry caches
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_registry_cache: Some(redis.clone()),
..Default::default()
},
..Default::default()
};Fields§
§group_cache: CacheEntryConfigGroup metadata cache (time_to_live). Default: 1h TTL, 250 entries.
device_registry_cache: CacheEntryConfigDevice registry cache (time_to_live). Default: 1h TTL, 1000 entries.
lid_pn_cache: CacheEntryConfigLID-to-phone cache. WAWebLidPnCache uses plain Maps with no expiry
and no size cap; evicting a still-valid mapping silently downgrades
Signal addresses to @c.us. Default: no timeout, capacity u64::MAX
(effectively unbounded — moka doesn’t expose an unbounded() builder).
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, 500 entries.
undecryptable_dispatched: CacheEntryConfigDedup key for UndecryptableMessage dispatch so a server resend of
the same id does not surface a second notification. Default: 5m TTL,
1000 entries.
pdo_pending_requests: CacheEntryConfigPDO pending requests (time_to_live). Default: 30s TTL, 200 entries.
sender_key_devices_cache: CacheEntryConfigSender key device tracking cache (time_to_idle). Default: 1h TTI, 500 entries. Caches per-group SKDM distribution state to avoid DB reads on every group send.
session_locks_capacity: u64Per-device Signal session lock capacity. Default: 10000.
chat_lanes_capacity: u64Per-chat lane capacity (combined lock + queue). Default: 5000.
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, chat_lanes), 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 (const: unstable) · 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