Skip to content

Commit 99ea734

Browse files
committed
sparkles: Add caffeine cache and reno notes, update tmux cheatsheet
1 parent e20242c commit 99ea734

5 files changed

Lines changed: 141 additions & 11 deletions

File tree

www/docs/.obsidian/appearance.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"accentColor": "#616161",
3-
"cssTheme": "Minimal",
3+
"cssTheme": "",
44
"translucency": false,
5-
"theme": "obsidian",
6-
"monospaceFontFamily": "JetBrainsMono Nerd Font Mono"
5+
"theme": "moonstone",
6+
"monospaceFontFamily": "JetBrainsMono Nerd Font Mono",
7+
"baseFontSize": 12
78
}

www/docs/.obsidian/workspace.json

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@
44
"type": "split",
55
"children": [
66
{
7-
"id": "5fd0405af0bddb0f",
7+
"id": "86d32c8db5d81679",
88
"type": "tabs",
99
"children": [
1010
{
11-
"id": "5c738946df7562c4",
11+
"id": "e7dd040f4c4e53f7",
1212
"type": "leaf",
1313
"state": {
14-
"type": "empty",
15-
"state": {}
14+
"type": "markdown",
15+
"state": {
16+
"file": "zettelkasten/infrastructure/tools/tmux.md",
17+
"mode": "source",
18+
"source": false
19+
}
1620
}
1721
}
1822
]
@@ -81,6 +85,7 @@
8185
"state": {
8286
"type": "backlink",
8387
"state": {
88+
"file": "zettelkasten/infrastructure/tools/tmux.md",
8489
"collapseAll": false,
8590
"extraContext": false,
8691
"sortOrder": "alphabetical",
@@ -97,6 +102,7 @@
97102
"state": {
98103
"type": "outgoing-link",
99104
"state": {
105+
"file": "zettelkasten/infrastructure/tools/tmux.md",
100106
"linksCollapsed": false,
101107
"unlinkedCollapsed": true
102108
}
@@ -118,7 +124,9 @@
118124
"type": "leaf",
119125
"state": {
120126
"type": "outline",
121-
"state": {}
127+
"state": {
128+
"file": "zettelkasten/infrastructure/tools/tmux.md"
129+
}
122130
}
123131
}
124132
]
@@ -138,8 +146,10 @@
138146
"command-palette:Open command palette": false
139147
}
140148
},
141-
"active": "5c738946df7562c4",
149+
"active": "e7dd040f4c4e53f7",
142150
"lastOpenFiles": [
151+
"zettelkasten/caffeine-refresh-vs-expire.md",
152+
"zettelkasten/reno_dump.md",
143153
"zettelkasten/finance/investing/options_basics.md",
144154
"zettelkasten/finance/investing/options_learning_plan.md",
145155
"zettelkasten/finance/investing/general/value_investing.md",
@@ -166,8 +176,6 @@
166176
"zettelkasten/finance/investing/options",
167177
"zettelkasten/finance/investing/diagonal_spreads.md",
168178
"zettelkasten/finance/investing/calendar_spreads.md",
169-
"zettelkasten/finance/investing/iron_condor.md",
170-
"zettelkasten/finance/investing/vertical_spreads.md",
171179
"zettelkasten/languages/go",
172180
"zettelkasten/languages",
173181
"zettelkasten/backend/languages/go/tooling",
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
🗓️ 06022026 1116
2+
3+
# caffeine-refresh-vs-expire
4+
5+
## Overview
6+
7+
| Feature | `expireAfterWrite` | `refreshAfterWrite` |
8+
|-----------------|-----------------------------------------------|------------------------------------------------------|
9+
| **Behavior** | Entry is **removed** after duration | Entry is **refreshed** asynchronously after duration |
10+
| **Stale reads** | No (returns null or recomputes synchronously) | Yes (returns stale value while refreshing) |
11+
| **Blocking** | Yes (on cache miss) | No (refresh happens in background) |
12+
| **Use case** | Data that must not be stale | Data where eventual consistency is acceptable |
13+
14+
## expireAfterWrite
15+
16+
Entries are **evicted** after the specified duration. The next request will block while the value is recomputed.
17+
18+
```java
19+
LoadingCache<String, User> cache = Caffeine.newBuilder()
20+
.expireAfterWrite(5, TimeUnit.MINUTES)
21+
.build(key -> userService.fetchUser(key));
22+
23+
// After 5 minutes, entry is removed
24+
// Next get() blocks until fetchUser() completes
25+
User user = cache.get("user123");
26+
```
27+
28+
**Timeline:**
29+
```
30+
t=0 -> cache.get("A") -> MISS, blocks, fetches, returns fresh value
31+
t=4min -> cache.get("A") -> HIT, returns cached value
32+
t=6min -> cache.get("A") -> MISS (expired), blocks, fetches, returns fresh value
33+
```
34+
35+
## refreshAfterWrite
36+
37+
Entries are **refreshed asynchronously** after the specified duration. The stale value is returned immediately while refresh happens in the background.
38+
39+
```java
40+
LoadingCache<String, User> cache = Caffeine.newBuilder()
41+
.refreshAfterWrite(5, TimeUnit.MINUTES)
42+
.expireAfterWrite(10, TimeUnit.MINUTES) // recommended: set expiry as upper bound
43+
.build(key -> userService.fetchUser(key));
44+
45+
// After 5 minutes, entry is marked for refresh
46+
// get() returns stale value immediately, triggers async refresh
47+
User user = cache.get("user123");
48+
```
49+
50+
**Timeline:**
51+
```
52+
t=0 -> cache.get("A") -> MISS, blocks, fetches, returns fresh value
53+
t=4min -> cache.get("A") -> HIT, returns cached value
54+
t=6min -> cache.get("A") -> HIT (stale), returns cached value, triggers async refresh
55+
t=6min+1ms -> refresh completes in background, cache updated
56+
t=7min -> cache.get("A") -> HIT, returns fresh value
57+
```
58+
59+
## Key Differences
60+
61+
### 1. Blocking Behavior
62+
63+
```java
64+
// expireAfterWrite: blocks on expired entry
65+
cache.get("key"); // blocks if expired
66+
67+
// refreshAfterWrite: never blocks (returns stale)
68+
cache.get("key"); // returns immediately, even if stale
69+
```
70+
71+
### 2. Combined Usage (Recommended)
72+
73+
Always pair `refreshAfterWrite` with `expireAfterWrite` as a **failsafe**:
74+
75+
```java
76+
Caffeine.newBuilder()
77+
.refreshAfterWrite(1, TimeUnit.MINUTES) // refresh after 1 min
78+
.expireAfterWrite(5, TimeUnit.MINUTES) // hard expiry after 5 min
79+
.build(loader);
80+
```
81+
82+
**Why is expireAfterWrite needed?**
83+
84+
`refreshAfterWrite` only triggers **on access**. The expiry acts as a safety net for edge cases:
85+
86+
| Scenario | Without expireAfterWrite | With expireAfterWrite |
87+
| ------------------------ | -------------------------------- | ----------------------- |
88+
| Key never accessed again | Stale data sits in cache forever | Evicted after 5 min |
89+
| Refresh throws exception | Stale value remains indefinitely | Evicted after 5 min |
90+
| Refresh keeps failing | Data becomes arbitrarily old | Hard limit on staleness |
91+
92+
**In normal operation** (frequent reads, successful refreshes), expireAfterWrite rarely triggers — the refresh keeps the entry fresh. It's a **worst-case bound**, not for typical flow.
93+
94+
## When to Use What
95+
96+
| Scenario | Recommendation |
97+
|----------|----------------|
98+
| User session data | `expireAfterWrite` (security-sensitive) |
99+
| Config/settings | `refreshAfterWrite` + `expireAfterWrite` |
100+
| External API responses | `refreshAfterWrite` + `expireAfterWrite` |
101+
| Rate limit counters | `expireAfterWrite` (must be accurate) |
102+
| Feature flags | `refreshAfterWrite` (eventual consistency OK) |
103+
104+
105+
---
106+
## References

www/docs/zettelkasten/infrastructure/tools/tmux.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
### Window commands (Group of splits)
2323
- `${NUMBER}` - Jumps to specified window
2424
- `p / n` - Previous / next window
25+
- `c` - **Create New Window** 
26+
- `,` - **Rename Current Window** 
27+
- **List Windows:** `Ctrl+b` then `w`.
28+
- `&`: **Kill Current Window** 
2529

2630
### Session commands (Group of windows)
2731
- `s` - List of sessions
@@ -33,6 +37,8 @@
3337
- `tmux attach -t ${session}` - attach to a specific session
3438
- `tmux detach` - detaches session from terminal
3539

40+
41+
3642
## Setup
3743
- https://github.com/tmux-plugins/tpm
3844

www/docs/zettelkasten/reno_dump.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
🗓️ 01022026 2223
2+
3+
# reno_dump
4+
- engineered wood flooring
5+
- cement screeding (?) or concrete
6+
- https://solluminaire.com.sg/
7+
8+
---
9+
## References

0 commit comments

Comments
 (0)