001package org.cache2k;
002
003/*
004 * #%L
005 * cache2k API only package
006 * %%
007 * Copyright (C) 2000 - 2016 headissue GmbH, Munich
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 * 
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 * 
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023/**
024 * Object representing a cache entry. With the cache entry it can be
025 * checked whether a mapping in the cache is present, even if the cache
026 * holds null or an exception.
027 *
028 * <p>After retrieved the entry instance does not change the values, even
029 * if the value for its key is updated in the cache.
030 *
031 * <p>Design remark: The cache is generally also aware of the time the
032 * object will be refreshed next or when it expired. This is not exposed
033 * to applications by intention.
034 *
035 * @author Jens Wilke; created: 2014-03-18
036 */
037public interface CacheEntry<K, T> {
038
039  K getKey();
040
041  T getValue();
042
043  Throwable getException();
044
045  /**
046   * Time the entry was last updated either by a fetch via the CacheSource
047   * or by a put. If the entry was never fetched yet 0 is returned.
048   */
049  long getLastModification();
050
051}