@@ -67,7 +67,7 @@ func main() {
67
67
config := zcache.LocalConfig {
68
68
// Ristretto cache configuration
69
69
NumCounters: 1e7 , // Number of keys to track frequency (default: 10M)
70
- MaxCost : 1 << 30 , // Maximum cost of cache (default: 1GB)
70
+ MaxCostMB : 1024 , // Maximum cost of cache in MB (default: 1024MB/ 1GB)
71
71
BufferItems: 64 , // Number of keys per Get buffer (default: 64)
72
72
73
73
// Metrics are required
@@ -98,7 +98,7 @@ func main() {
98
98
localConfig := zcache.LocalConfig {
99
99
// Ristretto cache configuration
100
100
NumCounters: 1e7 , // Number of keys to track (default: 10M)
101
- MaxCost : 1 << 29 , // Max memory usage - 512MB
101
+ MaxCostMB : 512 , // Max memory usage - 512MB
102
102
BufferItems: 64 , // Size of Get buffer
103
103
104
104
// Metrics are required
@@ -203,7 +203,7 @@ When using the local cache (Ristretto), memory is managed efficiently:
203
203
204
204
2 . ** Configuration Parameters** :
205
205
- ` NumCounters ` : Number of keys to track (default: 1e7 or 10 million)
206
- - ` MaxCost ` : Maximum memory cost of cache (default: 1 << 30 or 1GB)
206
+ - ` MaxCostMB ` : Maximum memory in MB (default: 1024MB or 1GB)
207
207
- ` BufferItems ` : Size of the Get buffer for handling concurrent operations (default: 64)
208
208
209
209
3 . ** TTL Behavior** :
@@ -231,7 +231,7 @@ For Redis metrics:
231
231
### Best Practices
232
232
1 . ** Memory Configuration** :
233
233
- Set appropriate ` NumCounters ` based on expected number of keys (~ 10x the items)
234
- - Configure ` MaxCost ` based on available system memory
234
+ - Configure ` MaxCostMB ` based on available system memory (in megabytes)
235
235
- Adjust ` BufferItems ` for high concurrency scenarios (default 64 is suitable for most cases)
236
236
237
237
2 . ** Production Recommendations** :
@@ -242,7 +242,7 @@ For Redis metrics:
242
242
243
243
3 . ** Cache Tuning** :
244
244
- For high-throughput systems, increase ` BufferItems `
245
- - For memory-constrained environments, decrease ` MaxCost ` appropriately
245
+ - For memory-constrained environments, decrease ` MaxCostMB ` appropriately
246
246
- Keep ` NumCounters ` at approximately 10x your expected item count for optimal hit ratio
247
247
248
248
### Notes
0 commit comments