Package javax.cache

Interface Cache.EntryProcessor<K,​V>

  • Type Parameters:
    K - the type of keys maintained by this cache
    V - the type of cached values
    Enclosing interface:
    Cache<K,​V>

    public static interface Cache.EntryProcessor<K,​V>
    Allows execution of code which may mutate a cache entry with exclusive access (including reads) to that entry.

    Any mutations will not take effect till after the processor has completed; if an exception thown inside the processor, no changes will be made to the cache.

    This enables a way to perform compound operations without transactions involving a cache entry atomically. Such operations may include mutations.

    The mutations can be potentially done in place avoiding expensive network transfers. An example is a value which is a list and you simply want to append a new element to it.

    An entry processor cannot invoke any cache operations, including processor operations.

    If executed in a JVM remote from the one invoke was called in, an EntryProcessor equal to the local one will execute the invocation. For remote to execution to succeed, the EntryProcessor implementation class must be in the excecuting class loader as must K and V if Cache.Entry.getKey() or Cache.Entry.getValue() is invoked.

    Author:
    Greg Luck, Yannis Cosmadopoulos
    • Method Detail

      • process

        Object process​(Cache.MutableEntry<K,​V> entry)
        Process an entry. Exclusive read and write access to the entry is obtained to the entry.
        Parameters:
        entry - the entry
        Returns:
        the result