Removes all expired image cache entries from the RFS cache.<p>

Empty directories are removed as well.<p>

@param maxAge the maximum age of the image cache files in hours (or fractions of hours)

@return the total number of deleted resources
190320
public static int cleanImageCache(float maxAge) {

        // calculate oldest possible date for the cache files
        long expireDate = System.currentTimeMillis() - (long)(maxAge * 60f * 60f * 1000f);
        File basedir = new File(CmsImageLoader.getImageRepositoryPath());
        // perform the cache cleanup
        return cleanImageCache(expireDate, basedir);
    }
25348
def _max_timestamps(dirname_full, remove, compare_tstamp):
    """"""
    tstamp = _get_timestamp_cached(dirname_full, remove)
    return max_none((tstamp, compare_tstamp))
740211
int refreshAndGetMax() {
		int max = 0;

		for (ResultSubpartition part : partition.getAllPartitions()) {
			int size = part.unsynchronizedGetNumberOfQueuedBuffers();
			max = Math.max(max, size);
		}

		return max;
	}
844007
int calculateMaxProgress(MappingTarget mappingTarget) {
    int batches = mappingTarget.getEntityMappings().stream().mapToInt(this::countBatches).sum();
    if (mappingTarget.hasSelfReferences()) {
      batches *= 2;
    }
    return batches;
  }
28009
func (st *Store) MaxAge(age int) {
	st.SessionOpts.MaxAge = age
	for _, codec := range st.Codecs {
		if sc, ok := codec.(*securecookie.SecureCookie); ok {
			sc.MaxAge(age)
		}
	}
}
93303
public long deleteAndCheckRangeEmpty(long key, long min, long max) {
        LLIndexPage pageKey = locatePageForKeyUnique(key, false);
		int posKey = pageKey.binarySearchUnique(0, pageKey.nEntries, key);
		//We assume that the key exists. Otherwise we get an exception anyway in the remove-method.
		//-> no such calculation: posKey = -(posKey+1);
		//First we cover the most frequent cases, which are also fastest to check.
		long[] keys = pageKey.getKeys();
		if (posKey > 0) {
			if (keys[posKey-1] >= min) {
                return pageKey.remove(key);
			}
			if (posKey < pageKey.nEntries-1) {
	            if (keys[posKey+1] <= max) {
	                return pageKey.remove(key);
	            }
	            //we are in the middle of the page surrounded by values outside the range
	            ind.file.reportFreePage(BitTools.getPage(key));
                return pageKey.remove(key);
			}
		} else if (posKey == 0 && pageKey.nEntries > 1) {
			if (keys[posKey+1] <= max) {
				return pageKey.remove(key);
			}
		}

		//brute force:
        long pos = pageKey.remove(key);
        LLEntryIterator iter = ind.iterator(min, max);
        if (!iter.hasNextULL()) {
            ind.file.reportFreePage(BitTools.getPage(key));
        }
        iter.close();
        return pos;
        
//        //If we get here, the key is on the border of the page and we need to search more.
//		//If we get here, we also know that there are no values from the range on the page.
//		
//		LLIndexPage pageMin = locatePageForKeyUnique(min, false);
//        if (pageKey != pageMin) {
////            System.out.println("X6");
//        	return pageKey.remove(key);
//        }
//        LLIndexPage pageMax = locatePageForKeyUnique(max, false);
//        if (pageKey != pageMax) {
////            System.out.println("X7");
//        	return pageKey.remove(key);
//        }
//
//        //Now we know that there are no range-keys on other pages either. We can remove the page.
//        
//        System.out.println("X8");
//		fsm.reportFreePage(BitTools.getPage(key));
//    	return pageKey.remove(key);
	}
468142
public T max() {
        TObjectIntIterator<T> iter = counts.iterator();
        int maxCount = -1;
        T max = null;
        while (iter.hasNext()) {
            iter.advance();
            int count = iter.value();
            if (count > maxCount) {
                max = iter.key();
                maxCount = count;
            }
        }
        return max;
    }
1316458
@SuppressWarnings("rawtypes")
	private final int removeEldestElementsFromCache(final IntLinkedHashMap<Node> hash, final int maxSize) {
		final int evict = hash.size() - maxSize;
		if (evict <= 0) {
			return 0;
		}

		for (int count = 0; count < evict; count++) {
			hash.removeEldest();
		}
		return evict;
	}
13211
public Integer getExpirationCache()
   {
      if (childNode.getTextValueForPatternName("expiration-cache") != null && !childNode.getTextValueForPatternName("expiration-cache").equals("null")) {
         return Integer.valueOf(childNode.getTextValueForPatternName("expiration-cache"));
      }
      return null;
   }
1208119
function purgeCacheIfNecessary () {
  // If max cache size has not been exceeded, do nothing
  if (cacheSizeInBytes <= maximumSizeInBytes) {
    return;
  }

  // Cache size has been exceeded, create list of images sorted by timeStamp
  // So we can purge the least recently used image
  function compare (a, b) {
    if (a.timeStamp > b.timeStamp) {
      return -1;
    }
    if (a.timeStamp < b.timeStamp) {
      return 1;
    }

    return 0;
  }
  cachedImages.sort(compare);

  // Remove images as necessary)
  while (cacheSizeInBytes > maximumSizeInBytes) {
    const lastCachedImage = cachedImages[cachedImages.length - 1];
    const imageId = lastCachedImage.imageId;

    removeImageLoadObject(imageId);

    triggerEvent(events, EVENTS.IMAGE_CACHE_PROMISE_REMOVED, { imageId });
  }

  const cacheInfo = getCacheInfo();

  triggerEvent(events, EVENTS.IMAGE_CACHE_FULL, cacheInfo);
}
1239331
protected function isFresh($destination, \DateTime $maxAge = null)
    {
        // fetch if file does not exist
        if (!file_exists($destination)) {
            return false;
        }

        // if file exists and no max-age is given, use the cached file
        if (!$maxAge instanceof \DateTime) {
            return true;
        }

        // download if ttl is passed
        $mtime = new \Datetime('@' . filemtime($destination));

        // see if cache has expired
        if ($mtime < $maxAge) {
            return false;
        }

        // check with last modified date (if available)
        if (($lastMod = $this->getLastModifiedDate()) && ($mtime < $lastMod)) {
            return false;
        }

        // all checks passed, use the cached version
        return true;
    }
97608
private void expungeExpiredEntries() {
        emptyQueue();
        if (lifetime == 0) {
            return;
        }
        int cnt = 0;
        long time = System.currentTimeMillis();
        for (Iterator<CacheEntry<K,V>> t = cacheMap.values().iterator();
                t.hasNext(); ) {
            CacheEntry<K,V> entry = t.next();
            if (entry.isValid(time) == false) {
                t.remove();
                cnt++;
            }
        }
        if (DEBUG) {
            if (cnt != 0) {
                System.out.println("Removed " + cnt
                        + " expired entries, remaining " + cacheMap.size());
            }
        }
    }
576042
@Delete
    public Maybe<Boolean> invalidateCaches() {
        return Flowable.fromIterable(cacheManager.getCacheNames())
                .map(cacheManager::getCache)
                .flatMap(c ->
                        Publishers.fromCompletableFuture(() -> c.async().invalidateAll())
                ).reduce((aBoolean, aBoolean2) -> aBoolean && aBoolean2);
    }
1341052
public function destroyExpiredCache()
    {
        $cacheData = $this->getCache();

        if (true === is_array($cacheData)) {
            $counter = 0;
            foreach ($cacheData as $key => $entry) {
                if (true === $this->isExpired($entry['time'], $entry['expire'])) {
                    unset($cacheData[$key]);
                    $counter++;
                }
            }

            if ($counter > 0) {
                $cacheData = json_encode($cacheData);
                @file_put_contents($this->getDirectory(), $cacheData);
            }

            return $counter;
        }
    }
747670
public static void deleteOldFiles(String dirPath, int olderThanMinute)  {

        File folder = new File(dirPath);
        if (folder.exists()) {
            File[] listFiles = folder.listFiles();
            long eligibleForDeletion = System.currentTimeMillis() - (olderThanMinute * 60 * 1000L);
            for (File listFile: listFiles) {
                if (listFile.lastModified() < eligibleForDeletion) {
                    if (!listFile.delete()) {
                        logger.error("Unable to delete file %s", listFile);
                    }
                }
            }
        }
    }
1278981
private void pruneIfNeeded(int neededSpace) {
        if ((mTotalSize + neededSpace) < mMaxCacheSizeInBytes) {
            return;
        }
//        if (JusLog.DEBUG) {
//            JusLog.v("Pruning old cache entries.");
//        }
        //todo add queue markers

        long before = mTotalSize;
        int prunedFiles = 0;
        long startTime = System.nanoTime();

        Iterator<Map.Entry<String, CacheHeader>> iterator = mEntries.entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry<String, CacheHeader> entry = iterator.next();
            CacheHeader e = entry.getValue();
            boolean deleted = getFileForKey(e.key).delete();
            if (deleted) {
                mTotalSize -= e.size;
            } else {
                //todo add queue markers
//               JusLog.d("Could not delete cache entry for key=%s, filename=%s",
//                       e.key, getFilenameForKey(e.key));
            }
            iterator.remove();
            prunedFiles++;

            if ((mTotalSize + neededSpace) < mMaxCacheSizeInBytes * HYSTERESIS_FACTOR) {
                break;
            }
        }
//todo add queue markers
//        if (JusLog.DEBUG) {
//            JusLog.v("pruned %d files, %d bytes, %d ms",
//                    prunedFiles, (mTotalSize - before), System.nanoTime() - startTime);
//        }
    }
716242
function(max) {
      var keys = [],
        cache = {};
      return {
        set: function(key, value) {
          if (keys.length > this.length) {
            delete cache[keys.shift()];
          }
          cache[key] = value;
          keys.push(key);
          return value;
        },
        get: function(key) {
          if (key === undefined) return cache;
          return cache[key];
        },
        length: max,
        len: function() {
          return keys.length;
        }
      };
    }