code: private Date clear() {
      Date date = new Date();
      Long timestamp = date.getTime();
      HashSet<String> idsToBeRemoved = new HashSet<>();
      // check expiration
      Iterator<Entry<String, Long>> expirationVersionEntryIterator = expirationVersion.entrySet().iterator();
      while(expirationVersionEntryIterator.hasNext()) {
        Entry<String, Long> entry = expirationVersionEntryIterator.next();
        if (entry.getValue() < timestamp) {
          String version = entry.getKey();
          if (versionToItem.containsKey(version)) {
            idsToBeRemoved.add(versionToItem.get(version).id);
          } else {
            log.debug("could not remove " + version);
          }
        }
      }
      for (String id : idsToBeRemoved) {
        deleteById(id);
      }
      idsToBeRemoved.clear();
      // check size
      if (expirationVersion.size() > maximumNumber + maximumOverflow) {
        Set<Entry<String, Long>> mapEntries = expirationVersion.entrySet();
        List<Entry<String, Long>> aList = new LinkedList<>(mapEntries);
        Collections.sort(aList,
            (Entry<String, Long> ele1, Entry<String, Long> ele2) -> ele2
                .getValue().compareTo(ele1.getValue()));
        aList.subList(maximumNumber, aList.size()).clear();
        Iterator<Entry<String, MtasSolrCollectionCacheItem>> versionToItemEntryIterator = versionToItem.entrySet().iterator();
        while(versionToItemEntryIterator.hasNext()) {
          Entry<String, MtasSolrCollectionCacheItem> entry = versionToItemEntryIterator.next();
          if (!expirationVersion.containsKey(entry.getKey())) {
            idsToBeRemoved.add(entry.getValue().id);
          }
        }
        for (String id : idsToBeRemoved) {
          deleteById(id);
        }
        idsToBeRemoved.clear();
      }
      return date;
    }
docs: Clear.
  
  @return the date