![]() In contrast to get(Object) this method solely operates Returns the value associated to the given key. Prevents it from being stored in this cache Throws: ClassCastException - if the class of the specified key Return different instances of the entry object. Parameters: key - key to retrieve the associated with the cache entry Returns: An entry representing the cache mapping. The alternative method peekEntry(K) can be used if the loader If null values are present the method can be used toĬheck for an existent mapping and retrieve the value in one API call. The exception can be retrieved via CacheEntry.getException(). In case the cache loader yields an exception, the entry object willīe returned. Until the loading is completed, details see CacheLoader If the loader is invoked, subsequent requests of the same key will block If no entry is present or the value is expired, either the loader is invoked Returns an entry that contains the cache value associated with the given key. Prevents it from being stored in this cache CacheLoaderException - if the loading produced an exception. Prevents it from being stored in this cache NullPointerException - if the specified key is null IllegalArgumentException - if some property of the specified key Previously associated null with the key) Throws: ClassCastException - if the class of the specified key (If nulls are permitted a null can also indicate that the cache Null if there was no mapping for the key. Specified by: get in interface KeyValueSource Parameters: key - key with which the specified value is associated Returns: the value associated with the specified key, or Details see CacheLoader.Īs an alternative peek(K) can be used if the loader should If the CacheLoader is invoked, subsequent requests of the same key will block Is expired the cache loader is invoked, if configured, or null is returned. Returns a value associated with the given key. Author: Jens Wilke See Also: to create a cache, ![]() To improve upward compatibility applications that need to implement this interface should useĪbstractCache or ForwardingCache. To allow arbitrary semantics that operate atomically on anĮntryProcessor can be implemented and executed via invoke(K, ).Ĭompatibility: Future versions of cache2k may introduce new methods to this interface. The accidental use of methods that do not invoke the loader transparentlyĪ subset interface, for example the KeyValueSource can be used.ĬAS-Operations: The cache has a set of operations that examine an entryĪnd do a mutation in an atomic way, for example putIfAbsent(K, V), containsAndRemove(K)Īnd replaceIfEquals(K, V, V). To make the code more obvious and protect against Methods, that do not interact with the loader such as containsKey(K) When using a cache loader theĪdditional methods for mutating the cache directly may not be needed. Populating: A cache may automatically populate its contents via a CacheLoader.įor typical read mostly caching this has several advantages,įor details see CacheLoader. It is important to note that the two assertion in the above example may fail.Ī cache has not the same guarantees as a data storage, because it needs to removeĬontent automatically as soon as resource limits are reached. Put(K, V) and peek(K) can be used, for example: In contrast to a HashMap theĬache allows concurrent access and modification to its content andĪutomatically controls the amount of entries in the cache to stay withinĪ cache can be obtained via a Cache2kBuilder, for example:īasic operation: To mutate and retrieve the cache content the operations Update values which are associated with keys. ![]() A cache is similar to a map or a key value store, allowing to retrieve and
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |