getStats method

Map<String, dynamic> getStats()

Returns statistics about the cache.

Useful for monitoring and debugging.

Implementation

Map<String, dynamic> getStats() {
  final all = getAll();
  return {
    'size': all.length,
    'maxSize': maxSize,
    'utilizationPercent': maxSize != null
        ? (all.length / maxSize! * 100).toStringAsFixed(1)
        : 'unlimited',
    'oldestEntry': _accessOrder.isNotEmpty ? _accessOrder.first : null,
    'newestEntry': _accessOrder.isNotEmpty ? _accessOrder.last : null,
  };
}