1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
use MemUsageTree;
use ChunkStoreEvent;
use EntityDb;
/// A cache for memoizing things in order to speed up immediate mode UI & other immediate mode style things.
///
/// Caches are stored in [`crate::StoreCache`], and each [`crate::StoreCache`] instance belongs to a
/// single [`re_log_types::StoreId`]. This means cache implementations are already scoped to one
/// store (recording or blueprint) and must not include the store id in their internal keys.
/// Caches that implement [`AppCache`] can also be stored in [`crate::AppCaches`].
///
/// Cache implementations may still need finer-grained keys, such as [`crate::ViewId`], entity paths,
/// timelines, or query ranges. In particular, view-related caches should explicitly decide whether
/// their data is truly per-view (`ViewId` key needed) or can be shared across all views of the same
/// store (`ViewId` key not needed).
///
/// See also egus's cache system, in [`egui::cache`] (<https://docs.rs/egui/latest/egui/cache/index.html>).
/// Marker for [`Cache`]es that can live in [`crate::AppCaches`].
///
/// Unlike per-store caches in [`crate::StoreCache`], app caches are not dropped together with a
/// store, and [`Cache::on_store_events`] is never called on them, also when the same cache type
/// implements it for its use in a [`crate::StoreCache`].
/// Therefore, only caches whose keys are globally unique, e.g. content-addressed by row id,
/// and whose entries expire on their own via [`Cache::begin_frame`] implement this.
/// Trait for [`Cache`]es that are internally a list of key-value pairs that are computed once
/// and can be trivially returned without holding the lock.
///
/// Implementing this is required for [`crate::StoreCache::memoizer_read_or_compute`].
///
/// If computing a value needs data beyond the persistent cache key, use an accessor type for
/// `Key` that contains both the stable key and borrowed inputs for the miss path.
/// [`Self::read`] should only use the stable key, while [`Self::compute`] may use the additional
/// inputs.