@asamuzakjp/generational-cache 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -22
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -118,28 +118,7 @@ Benchmarks are divided into two states to simulate real-world conditions:
|
|
|
118
118
|
* **High Eviction Efficiency**: `GenerationalCache` demonstrates strong throughput during high-turnover workloads, maintaining a performance margin compared to standard LRU designs in large-scale eviction scenarios.
|
|
119
119
|
* **Predictable Scalability**: While other libraries may experience performance degradation as cache size increases, `GenerationalCache` maintains consistent throughput due to its generational swap mechanism.
|
|
120
120
|
* **Balanced Read/Write**: It provides stable and competitive performance across all basic operations (`get`, `set`), making it suitable for both read-heavy and write-heavy environments.
|
|
121
|
-
* **Trade-offs**: In cyclic access patterns where the working set is greater than `max / 2` but smaller than `max`, `GenerationalCache` will experience frequent generation swaps and cache misses.
|
|
122
|
-
|
|
123
|
-
## Conclusion: When to Use GenerationalCache
|
|
124
|
-
|
|
125
|
-
`GenerationalCache` is not a one-size-fits-all solution.
|
|
126
|
-
Its effectiveness depends on the ratio between your **Working Set Size ($W$)** and the **Cache Capacity ($S$)**.
|
|
127
|
-
|
|
128
|
-
### 1. High-Turnover Environments ($W \ge S$)
|
|
129
|
-
This is the primary use case for `GenerationalCache`.
|
|
130
|
-
When your working set is larger than the cache size, evictions occur constantly.
|
|
131
|
-
* **Use case**: High-traffic APIs, memory-constrained containers, or streaming data where maintaining high system throughput is more critical than a perfect hit rate.
|
|
132
|
-
|
|
133
|
-
### 2. Over-Provisioned Environments ($S \ge 2W$)
|
|
134
|
-
If you have abundant memory, `GenerationalCache` operates as an ultra-low-overhead "passive" cache.
|
|
135
|
-
* **Use case**: Static master data or "hot" lookups where you want to minimize CPU cycles and maintain consistent sub-microsecond latency without any internal pointer updates.
|
|
136
|
-
|
|
137
|
-
### Avoid ($S/2 < W < S$)
|
|
138
|
-
Be cautious when your working set is larger than half the cache but smaller than the total capacity.
|
|
139
|
-
In this specific range, a standard LRU might achieve a 100% hit rate, while `GenerationalCache` will experience periodic misses due to generation swaps.
|
|
140
|
-
|
|
141
|
-
* **For Stability**: Set **$S \ge 2W$** (Eliminate swap misses)
|
|
142
|
-
* **For Throughput**: Set **$S < W$** (Maximize eviction speed)
|
|
121
|
+
* **Trade-offs**: In cyclic access patterns where the working set is greater than `max / 2` but smaller than `max`, `GenerationalCache` will experience frequent generation swaps and cache misses. To maximize the performance benefits of `GenerationalCache`, it is often better to keep the `max` size small enough to allow some evictions, rather than trying to fit the entire working set.
|
|
143
122
|
|
|
144
123
|
## License
|
|
145
124
|
|
package/package.json
CHANGED