pub struct CacheConfig {Show 21 fields
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 pdo_requested: CacheEntryConfig,
pub sender_key_devices_cache: CacheEntryConfig,
pub session_recreate_history: CacheEntryConfig,
pub session_locks_capacity: u64,
pub chat_lanes_capacity: u64,
pub group_distribution_locks_capacity: u64,
pub resend_rate_limiter_capacity: u64,
pub sent_message_ttl_secs: u64,
pub msg_secret_policy: MsgSecretPolicy,
pub msg_secret_retention: MsgSecretRetention,
pub seed_msg_secrets_from_history: bool,
pub original_message_resolver: Option<Arc<dyn OriginalMessageResolver>>,
pub msg_secret_resolver_timeout: Duration,
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, 5000 entries (holds a large group’s per-member device set; a near-max group is ~1024).
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 — the cache has no dedicated 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: 1h TTL, 500 entries. Long enough that the MAX_DECRYPT_RETRIES cap survives spaced redeliveries.
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.
pdo_requested: CacheEntryConfigMessages already covered by a placeholder-resend PDO request
(time_to_live). WA Web keeps a session-lifetime set
(WAWebNonMessageDataRequestPlaceholderMessageResendUtils) so each
message triggers at most one request; without it, every redelivery of
an undecryptable message re-asks the phone (a stuck sender resending
every ~11s produced ~700 requests in 3h). The TTL stands in for
“session lifetime” with bounded memory. Default: 24h TTL, 512 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_recreate_history: CacheEntryConfigSession-recreate throttle history (time_to_live). Default: 1h TTL, 256
entries. Replaces a global Mutex<HashMap> scanned O(n) per retry receipt.
session_locks_capacity: u64Per-device Signal session lock capacity. Default: 10000. Soft cap: a lock a task is actively holding is never evicted, so the map can briefly exceed this under heavy concurrent fan-out (bounded by the concurrently-held count) rather than evicting a live lock and letting two writers race the same session.
chat_lanes_capacity: u64Per-chat lane capacity (combined lock + queue). Default: 5000.
group_distribution_locks_capacity: u64Per-group cold sender-key distribution lock capacity. Default: 512. Soft cap: a live lane is never evicted, so the map may briefly exceed this under concurrent fan-out instead of breaking tracker ordering.
resend_rate_limiter_capacity: u64Per-chat resend rate-limiter capacity: one token-bucket entry per group recently driving retry resends. Keep above the count of concurrently storming groups: eviction is FIFO and fail-open (an evicted bucket is recreated full), so undersizing only forgives rate, never over-throttles. Default: 4096.
sent_message_ttl_secs: u64TTL in seconds for sent messages in DB before periodic cleanup. Must outlive retry receipts (which can arrive well after a send) or the retry is dropped as “not found in cache”. The periodic sweep keeps the table bounded. 0 = no automatic cleanup. Default: 7200 (2 hours).
msg_secret_policy: MsgSecretPolicyHow the per-message messageSecret store is managed (capture / seed /
prune). Default MsgSecretPolicy::Managed bounds DB growth: it seeds
only the still-relevant slice of history and prunes by a per-add-on-kind
event-time horizon. Set MsgSecretPolicy::Full to keep everything
forever, or MsgSecretPolicy::Disabled to persist nothing and delegate
to original_message_resolver.
msg_secret_retention: MsgSecretRetentionPer-add-on-kind retention horizons applied under Managed/BotOnly.
seed_msg_secrets_from_history: boolWhether to seed messageSecrets from history-sync blobs. Default true.
Independent of live capture (which msg_secret_policy governs): seeding
only matters for add-ons that arrive live after connect yet reference a
parent delivered via history sync — edits of just-pre-pairing messages,
add-options/edits on still-open polls, or replays to a reconnecting
offline device. Headless consumers that only react to new messages can
set this to false to skip the pairing-time seed entirely. When true,
the policy still filters the seed (age/type under Managed, bot-only
under BotOnly, everything under Full).
original_message_resolver: Option<Arc<dyn OriginalMessageResolver>>Optional app-supplied fallback consulted when an add-on’s parent secret
is absent from the store (and its LID/PN alternates). Lets an app that
keeps its own message store own secret retention; required for the
Disabled policy to decrypt anything beyond what it has seen live.
msg_secret_resolver_timeout: DurationBound on each original_message_resolver call. The resolver runs
inside the per-chat receive lane, so a slow callback would stall that
chat; on timeout the lookup degrades to a miss. Default: 5s.
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 cache. Fields left as
None keep the default in-process 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 !RefUnwindSafe for CacheConfig
impl !UnwindSafe for CacheConfig
impl Freeze for CacheConfig
impl Send for CacheConfig
impl Sync for CacheConfig
impl Unpin for CacheConfig
impl UnsafeUnpin 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
impl<T> ErasedDestructor for Twhere
T: 'static,
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