Commit 730798c
Add caching for gem version comparison to improve performance
Optimize version validation by caching comparison results to avoid
repeated normalization on every rendering request.
**Changes:**
- Add `versionCache` Map to store version comparison results
- Cache is checked before performing normalization (key: gemVersion)
- Normalization only runs on cache miss
- Production logging is now conditional on cache miss (logs only once)
**Performance benefits:**
- Eliminates repeated string operations (trim, toLowerCase, regex) on every request
- Prevents log spam in production (warning logged only once per unique version)
- Minimal memory overhead (few cached version strings)
**Cache behavior:**
- Cache key: gemVersion string
- Cache value: boolean (true if versions match, false if mismatch)
- If key exists, comparison result is used directly
- Production warning only logs when version is first encountered (justCached flag)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent e04c313 commit 730798c
File tree
1 file changed
+23
-4
lines changed- react_on_rails_pro/packages/node-renderer/src/worker
1 file changed
+23
-4
lines changedLines changed: 23 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
11 | 16 | | |
12 | 17 | | |
13 | 18 | | |
| |||
53 | 58 | | |
54 | 59 | | |
55 | 60 | | |
56 | | - | |
57 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
58 | 73 | | |
59 | | - | |
| 74 | + | |
| 75 | + | |
60 | 76 | | |
61 | 77 | | |
62 | 78 | | |
63 | 79 | | |
64 | 80 | | |
65 | 81 | | |
66 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
67 | 86 | | |
68 | 87 | | |
69 | 88 | | |
| |||
0 commit comments