toString method

  1. @override
String toString()
override

Returns a string representation of the cache, including statistics such as maximum size, hit count, miss count, and hit rate percentage.

Implementation

@override
String toString() {
  final int accesses = hitCount + missCount;
  final int hitPercent = accesses != 0 ? (100 * hitCount ~/ accesses) : 0;
  return '${runtimeType} [ '
      'maxSize=$maxSize, '
      'hits=$hitCount, '
      'misses=$missCount, '
      'hitRate=$hitPercent% ]';
}