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.
///
/// Derive or implement this trait when you want domain-shaped cache calls
/// without repeating entity and collection names at every query site.
///
/// # Example
///
/// ```rust
/// use hydracache_db::{CacheEntity, HydraCacheEntity};
///
/// #[derive(HydraCacheEntity)]
/// #[hydracache(entity = "user", collection = "users")]
/// struct User {
/// #[hydracache(id)]
/// id: i64,
/// }
///
/// 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()));
/// ```
///
/// Use `#[hydracache(id = Type)]` on the struct when the id type is generated
/// or otherwise not represented by one named field.