Skip to content

Commit 92d78d2

Browse files
authored
docs: update arch docs (#1132)
1 parent fe48121 commit 92d78d2

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,41 @@
11
# Architecture
22

3+
This blog introduces the architecture design of ***foyer*** from a top-down perspective.
4+
5+
## 1. Hybrid Cache
6+
7+
***foyer*** is a hybrid caching system that combines in-memory cache and disk cache. It automatically manages the behavior and lifecycle of cache entries between the in-memory cache and the disk cache.
8+
9+
Obviously, ***foyer*** consists of three components to provide hybrid cache functionality.
10+
11+
1. **Memory Cache (provided by crate `foyer-memory`):** Pure in-memory cache library. Similar to other in-memory cache libraries, it provides functionalities such as adding, deleting, updating, and querying cache entries. Besides, to be compatible with the disk cache, it also provides optimizations such as request merging and support for asynchronous interfaces. (This crate can be used separately as a pure in-memory cache with minimal overhead.)
12+
2. **Disk Cache (provided by crate `foyer-storage`):** Includes the disk cache engines, IO engines, and device driver layer. It cannot be used independently and can only be utilized through ***foyer***.
13+
3. **Cooperator (Integrated in crate `foyer`):** A lightweight wrapper to coordinate in-memory cache and disk cache.
14+
15+
<div style="text-align:center">
16+
17+
![hybrid-cache](assets/hybrid-cache.svg)
18+
19+
</div>
20+
21+
Besides the hybrid cache mode, ***foyer*** can also operate as a pure in-memory cache in compatibility mode. This mode doesn't require any API modifications based on the hybrid cache and is therefore suitable for systems that need both pure in-memory cache and hybrid cache operation. In this mode, ***foyer*** provisions a no-op disk cache engine. This introduces only a minimal overhead in exchange for API compatibility.
22+
23+
<div style="text-align:center">
24+
25+
![hybrid-cache-compatible-mode](assets/hybrid-cache-compatible-mode.svg)
26+
27+
</div>
28+
29+
If you only need to use ***foyer*** as a pure in-memory cache, you can directly use `Cache` instead of `HybridCache`. `Cache` is a re-export from the `foyer-memory` crate. It provides APIs and usage similar to mainstream cache libraries, and also offers all the features of the in-memory cache part within the ***foyer*** hybrid cache, including: interchangeable cache algorithms, request deduplication optimization, etc.
30+
31+
32+
<div style="text-align:center">
33+
34+
![cache](assets/cache.svg)
35+
36+
</div>
37+
38+
## 2. Memory Cache
39+
340
***TBC ... ...***
41+

website/docs/05-design/assets/cache.svg

Lines changed: 4 additions & 0 deletions
Loading

website/docs/05-design/assets/hybrid-cache-compatible-mode.svg

Lines changed: 4 additions & 0 deletions
Loading

website/docs/05-design/assets/hybrid-cache.svg

Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)