ensureCacheBelowMaxMemory method

int ensureCacheBelowMaxMemory([
  1. int extraMemoryNeeded = 0
])

Implementation

int ensureCacheBelowMaxMemory([int extraMemoryNeeded = 0]) {
  if (!hasMaxCacheMemory) return 0;

  if (extraMemoryNeeded > 0) {
    var maxMem2 = maxCacheMemory - extraMemoryNeeded;
    if (maxMem2 < 10) {
      clearCache();
      return 0;
    } else {
      return cleanCache(maxMem2);
    }
  } else if (hasMaxCacheMemory) {
    return cleanCache(maxCacheMemory);
  }

  return 0;
}