class AbstractCache implements IDataCache<T> {

  @Override
  public void cacheData(T data) {
    if (!dataIsCachable(data) || dataIsInCache(data.getId())) {
      return;
    }

    if (data.getByteSize() > maxCacheSize) {
      return;
    }

    lock.writeLock().lock();
    try {
      while (!hasStorageFor(data.getByteSize())) {
        removeEntryByCachingStrategy();
      }
      addEntry(createEntry(data));
    } finally {
      lock.writeLock().unlock();
    }
  }

  public  AbstractCache(S entries, IDataStorage<T> cachedStorage, long maxCacheSize,
      Predicate<T> cachingRule);

}