Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Copyright (c) 2011 Terracotta, Inc.
* Copyright (c) 2011 Oracle and/or its affiliates.
*
* All rights reserved. Use is subject to license terms.
*/
package javax.cache;
import javax.cache.event.CacheEntryListener;
import javax.cache.mbeans.CacheMXBean;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Future;
/**
* A Cache provides storage of data for later fast retrieval.
*
* This Cache interface is based on {@link java.util.concurrent.ConcurrentMap} with some modifications for
* fast distributed performance.
*
* A Cache does not allow null keys or values. Attempts to store a null value or
* to use a null key either in a get or put operation will result in a {@link NullPointerException}.
*
* Caches use generics throughout providing a level of type safety akin to the collections package.
*
* Cache implements {@link Iterable} for {@link javax.cache.Cache.Entry}, providing support for simplified iteration.
* However iteration should be used with caution. It is an O(n) operation and may be
* slow on large or distributed caches.
*
* The Cache API also provides:
*
*
read-through caching
*
write-through caching
*
cache loading
*
cache listeners
*
statistics
*
lifecycle
*
configuration
*
* Though not visible in the Cache interface caches may be optionally transactional.
*
* User programs may make use of caching annotations to interact with a cache.
*
* A simple example of how to use a cache is:
*
* Concurrency is described as if there exists a locking mechanism on each key. If a cache operation gets an exclusive lock on a key,
* then all subsequent operations on that key will block until that lock is released. The consequences are that operations performed by a
* thread happen-before read or mutation operations performed by another thread, including threads in different Java Virtual Machines.
*
* @param the type of keys maintained by this cache
* @param the type of cached values
* @author Greg Luck
* @author Yannis Cosmadopoulos
* @since 1.0
*/
public interface Cache extends Iterable>, CacheLifecycle {
/**
* Gets an entry from the cache.
*
* If the cache is configured read-through, and get would return null because the entry
* is missing from the cache, the Cache's {@link CacheLoader} is called which will attempt
* to load the entry.
*
*
Read-Through - will use the {@link CacheLoader} if enabled and key not present in cache
*
*
* @param key the key whose associated value is to be returned
* @return the element, or null, if it does not exist.
* @throws IllegalStateException if the cache is not {@link Status#STARTED}
* @throws NullPointerException if the key is null
* @throws CacheException if there is a problem fetching the value
* @see java.util.Map#get(Object)
*/
V get(K key);
/**
* The getAll method will return, from the cache, a {@link java.util.Map} of the objects
* associated with the Collection of keys in argument "keys".
*
* If the cache is configured read-through, and a get would return null because an entry
* is missing from the cache, the Cache's {@link CacheLoader} is called which will attempt
* to load the entry. This is done for each key in the collection for which this is the case.
* If an entry cannot be loaded for a given key, the key will not be present in the returned Map.
*
*
* @param keys The keys whose associated values are to be returned.
* @return A map of entries that were found for the given keys. Keys not found in the cache are not in the returned map.
* @throws NullPointerException if keys is null or if keys contains a null
* @throws IllegalStateException if the cache is not {@link Status#STARTED}
* @throws CacheException if there is a problem fetching the values.
*/
Map getAll(Set extends K> keys);
/**
* Returns true if this cache contains a mapping for the specified
* key. More formally, returns true if and only if
* this cache contains a mapping for a key k such that
* key.equals(k). (There can be at most one such mapping.)
*
*
* @param key key whose presence in this cache is to be tested.
* @return true if this map contains a mapping for the specified key
* @throws NullPointerException if key is null
* @throws IllegalStateException if the cache is not {@link Status#STARTED}
* @throws CacheException it there is a problem checking the mapping
* @see java.util.Map#containsKey(Object)
*/
boolean containsKey(K key);
/**
* The load method provides a means to "pre-load" the cache. This method
* will, asynchronously, load the specified object into the cache using
* the associated {@link CacheLoader} for the given key.
*
* If the object already exists in the cache, no action is taken and null is returned.
* If no loader is associated with the cache no object will be loaded into the cache and null is returned.
*
* If a problem is encountered during the retrieving or loading of the object, an exception
* must be propagated on {@link java.util.concurrent.Future#get()} as a {@link java.util.concurrent.ExecutionException}
*
* @param key the key
* @return a Future which can be used to monitor execution.
* @throws NullPointerException if key is null.
* @throws IllegalStateException if the cache is not {@link Status#STARTED}
* @throws CacheException if there is a problem doing the load
*/
Future load(K key);
/**
* The loadAll method provides a means to "pre-load" objects into the cache.
* This method will, asynchronously, load the specified objects into the
* cache using the associated cache loader for the given keys.
*
* If the an object already exists
* in the cache, no action is taken. If no loader is associated with the
* object, no object will be loaded into the cache. If a problem is
* encountered during the retrieving or loading of the objects, an
* exception (to be defined) should be logged.
*
* If a problem is encountered during the retrieving or loading of the object, an exception
* must be propagated on {@link java.util.concurrent.Future#get()} as a {@link java.util.concurrent.ExecutionException}
*
* @param keys the keys
* @return a Future which can be used to monitor execution
* @throws NullPointerException if keys is null or if keys contains a null.
* @throws IllegalStateException if the cache is not {@link Status#STARTED}
* @throws CacheException if there is a problem doing the load
*/
Future