* Get cache statistics.
()
| 275 | * Get cache statistics. |
| 276 | */ |
| 277 | getStats(): { |
| 278 | size: number; |
| 279 | maxSize: number; |
| 280 | hits: number; |
| 281 | misses: number; |
| 282 | evictions: number; |
| 283 | hitRate: string; |
| 284 | } { |
| 285 | const total = this.stats.hits + this.stats.misses; |
| 286 | const hitRate = total > 0 ? ((this.stats.hits / total) * 100).toFixed(1) + "%" : "0%"; |
| 287 | |
| 288 | return { |
| 289 | size: this.cache.size, |
| 290 | maxSize: this.config.maxSize, |
| 291 | hits: this.stats.hits, |
| 292 | misses: this.stats.misses, |
| 293 | evictions: this.stats.evictions, |
| 294 | hitRate, |
| 295 | }; |
| 296 | } |
| 297 | |
| 298 | /** |
| 299 | * Clear all cached entries. |