Skip to main content

dialcache/
limits.rs

1//! Numeric domains shared by every DialCache implementation.
2
3/// Largest integer JavaScript represents exactly; timestamps and counters
4/// beyond it are rejected rather than rounded.
5pub const MAX_SAFE_INTEGER: u64 = 9_007_199_254_740_991;
6/// Fixed 365-day ceiling shared by cache TTLs and invalidation buffers, in milliseconds.
7pub const MAX_SUPPORTED_DURATION_MS: u64 = 365 * 24 * 60 * 60 * 1_000;
8/// Cache TTL ceiling in whole seconds.
9pub const MAX_CACHE_TTL_SEC: u64 = MAX_SUPPORTED_DURATION_MS / 1_000;
10/// Tracked Redis values are physically retained for at most one hour so
11/// invalidation markers can safely age out.
12pub const MAX_TRACKED_VALUE_TTL_MS: u64 = 60 * 60 * 1_000;
13/// Largest source or read deadline, in milliseconds.
14pub const MAX_DEADLINE_MS: u64 = 2_147_483_647;
15/// Library default remote read budget.
16pub const DEFAULT_REMOTE_READ_TIMEOUT_MS: u64 = 50;
17/// Library default source budget.
18pub const DEFAULT_FALLBACK_TIMEOUT_MS: u64 = 60_000;
19/// Default process-local capacity per instance.
20pub const DEFAULT_LOCAL_CAPACITY: usize = 10_000;
21/// Default concurrent shadow jobs per instance.
22pub const DEFAULT_SHADOW_MAX_IN_FLIGHT: usize = 1;
23/// Ceiling on one decompressed payload (Redis's own value limit).
24pub const MAX_DECOMPRESSED_BYTES: usize = 512 * 1024 * 1024;
25/// Default compression threshold in serialized bytes.
26pub const DEFAULT_COMPRESSION_THRESHOLD_BYTES: usize = 4096;
27/// Default zstd level.
28pub const DEFAULT_ZSTD_LEVEL: i32 = 3;
29/// Reserved use case name owned by invalidation watermarks.
30pub const WATERMARK_USE_CASE: &str = "watermark";
31/// Key suffix of every stored value frame.
32pub const FRAME_KEY_SUFFIX: &str = ":dialcache-frame-v1";
33/// Minimum watermark retention: twice the tracked value cap.
34pub const MIN_WATERMARK_TTL_MS: u64 = 2 * MAX_TRACKED_VALUE_TTL_MS;
35/// Slack added to derived watermark retention.
36pub const WATERMARK_TTL_MARGIN_MS: u64 = 60_000;