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
use CacheKeyBuilder;
/// Static cache metadata for a domain entity.
///
/// Implement this trait manually when you want domain-shaped cache calls without
/// repeating entity and collection names at every query site. A future derive
/// macro can generate the same implementation.
///
/// # Example
///
/// ```rust
/// use hydracache_db::CacheEntity;
///
/// struct User;
///
/// impl CacheEntity for User {
/// type Id = i64;
///
/// const ENTITY: &'static str = "user";
/// const COLLECTION: Option<&'static str> = Some("users");
/// }
///
/// assert_eq!(User::cache_key_for(&42), "user:42");
/// assert_eq!(User::entity_tag_for(&42), "user:42");
/// assert_eq!(User::collection_tag(), Some("users".to_owned()));
/// ```