Skip to content

Commit c4cdcd5

Browse files
committed
amendments
1 parent 1c81ebf commit c4cdcd5

2 files changed

Lines changed: 55 additions & 27 deletions

File tree

cache/docs/DETAILED.md

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -232,26 +232,54 @@ Cache Key: gogGlosses:https://example.org/manuscript/123:50:0
232232
Returns cache performance metrics:
233233
```json
234234
{
235-
"stats": {
236-
"hits": 1234,
237-
"misses": 456,
238-
"hitRate": "73.02%",
239-
"size": 234,
240-
"maxSize": 1000,
241-
"invalidations": 89
242-
}
235+
"hits": 1234,
236+
"misses": 456,
237+
"hitRate": "73.02%",
238+
"evictions": 12,
239+
"sets": 1801,
240+
"invalidations": 89,
241+
"length": 234,
242+
"bytes": 2457600,
243+
"lifespan": "5 minutes 32 seconds",
244+
"maxLength": 1000,
245+
"maxBytes": 1000000000,
246+
"ttl": 300000
243247
}
244248
```
245249

246250
**With Details** (`?details=true`):
247251
```json
248252
{
249-
"stats": { ... },
250-
"details": {
251-
"keys": ["id:123", "query:{...}", ...],
252-
"oldestEntry": "2025-01-15T10:23:45.678Z",
253-
"newestEntry": "2025-01-15T14:56:12.345Z"
254-
}
253+
"hits": 1234,
254+
"misses": 456,
255+
"hitRate": "73.02%",
256+
"evictions": 12,
257+
"sets": 1801,
258+
"invalidations": 89,
259+
"length": 234,
260+
"bytes": 2457600,
261+
"lifespan": "5 minutes 32 seconds",
262+
"maxLength": 1000,
263+
"maxBytes": 1000000000,
264+
"ttl": 300000,
265+
"details": [
266+
{
267+
"position": 0,
268+
"key": "id:507f1f77bcf86cd799439011",
269+
"age": "2 minutes 15 seconds",
270+
"hits": 45,
271+
"length": 183,
272+
"bytes": 183
273+
},
274+
{
275+
"position": 1,
276+
"key": "query:{\"type\":\"Annotation\"}",
277+
"age": "5 minutes 2 seconds",
278+
"hits": 12,
279+
"length": 27000,
280+
"bytes": 27000
281+
}
282+
]
255283
}
256284
```
257285

cache/docs/TESTS.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
The cache testing suite includes two test files that provide comprehensive coverage of the RERUM API caching layer:
66

7-
1. **`cache.test.js`** - Middleware functionality tests (48 tests)
7+
1. **`cache.test.js`** - Middleware functionality tests (36 tests)
88
2. **`cache-limits.test.js`** - Limit enforcement tests (12 tests)
99

1010
## Test Execution
@@ -26,15 +26,15 @@ npm run runtest -- cache/__tests__/cache-limits.test.js
2626
### Expected Results
2727
```
2828
✅ Test Suites: 2 passed, 2 total
29-
✅ Tests: 60 passed, 60 total
30-
⚡ Time: ~1.2s
29+
✅ Tests: 48 passed, 48 total
30+
⚡ Time: ~1.5s
3131
```
3232

3333
---
3434

35-
## cache.test.js - Middleware Functionality (48 tests)
35+
## cache.test.js - Middleware Functionality (36 tests)
3636

37-
### ✅ Read Endpoint Caching (30 tests)
37+
### ✅ Read Endpoint Caching (26 tests)
3838

3939
#### 1. cacheQuery Middleware (5 tests)
4040
- ✅ Pass through on non-POST requests
@@ -85,8 +85,8 @@ npm run runtest -- cache/__tests__/cache-limits.test.js
8585
### ✅ Cache Management (4 tests)
8686

8787
#### cacheStats Endpoint (2 tests)
88-
- ✅ Return cache statistics (hits, misses, hitRate, size)
89-
- ✅ Include details when requested with `?details=true`
88+
- ✅ Return cache statistics at top level (hits, misses, hitRate, length, bytes, etc.)
89+
- ✅ Include details array when requested with `?details=true`
9090

9191
#### cacheClear Endpoint (1 test)
9292
- ✅ Clear all cache entries
@@ -290,7 +290,7 @@ bash /tmp/test_history_since_caching.sh
290290

291291
### Unit Tests (cache.test.js) - What They're Good For
292292

293-
**Fast** - 0.33 seconds for 36 tests
293+
**Fast** - ~1.5 seconds for 36 tests
294294
**Isolated** - No database or server required
295295
**Focused** - Tests individual middleware functions
296296
**Reliable** - No flaky network/database issues
@@ -630,7 +630,7 @@ These tests run automatically in the CI/CD pipeline:
630630
631631
## Performance
632632
633-
Test execution is fast (~400ms) because:
633+
Test execution is fast (~1.5s) because:
634634
- No database connections required
635635
- Pure in-memory cache operations
636636
- Mocked HTTP request/response objects
@@ -650,9 +650,9 @@ Update tests when:
650650
### Test Review Checklist
651651
652652
Before merging cache changes:
653-
- [ ] All 25 tests passing
653+
- [ ] All 48 tests passing (36 middleware + 12 limits)
654654
- [ ] New endpoints have corresponding tests
655-
- [ ] Cache behavior verified manually (see TEST_RESULTS.md)
655+
- [ ] Cache behavior verified manually
656656
- [ ] Documentation updated
657657
658658
## Related Documentation
@@ -664,7 +664,7 @@ Before merging cache changes:
664664
---
665665
666666
**Test Coverage Summary**:
667-
- **cache.test.js**: 48 tests covering middleware functionality
667+
- **cache.test.js**: 36 tests covering middleware functionality
668668
- **cache-limits.test.js**: 12 tests covering limit enforcement
669-
- **Total**: 60 tests, all passing ✅
669+
- **Total**: 48 tests, all passing ✅
670670
- **Last Updated**: October 21, 2025

0 commit comments

Comments
 (0)