Interface NamedCache<K,​V>

    • Method Detail

      • getCacheName

        String getCacheName()
        Return the cache name.
        Returns:
        the cache name
      • getCacheService

        CacheService getCacheService()
        Return the CacheService that this NamedCache is a part of.
        Returns:
        the CacheService
      • put

        V put​(K key,
              V value,
              long cMillis)
        Associates the specified value with the specified key in this cache and allows to specify an expiry for the cache entry.

        Note: Though NamedCache interface extends CacheMap, not all implementations currently support this functionality.

        For example, if a cache is configured to be a replicated, optimistic or distributed cache then its backing map must be configured as a local cache. If a cache is configured to be a near cache then the front map must to be configured as a local cache and the back map must support this feature as well, typically by being a distributed cache backed by a local cache (as above.)

        Specified by:
        put in interface CacheMap<K,​V>
        Parameters:
        key - key with which the specified value is to be associated
        value - value to be associated with the specified key
        cMillis - the number of milliseconds until the cache entry will expire, also referred to as the entry's "time to live"; pass CacheMap.EXPIRY_DEFAULT to use the cache's default time-to-live setting; pass CacheMap.EXPIRY_NEVER to indicate that the cache entry should never expire; this milliseconds value is not a date/time value, such as is returned from System.currentTimeMillis()
        Returns:
        previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key, if the implementation supports null values
        Throws:
        UnsupportedOperationException - if the requested expiry is a positive value and the implementation does not support expiry of cache entries
        Since:
        Coherence 2.3
      • async

        default AsyncNamedCache<K,​V> async()
        Return an asynchronous wrapper for this NamedCache.

        By default, the order of execution of asynchronous operation invoked on the returned AsyncNamedCache will be preserved by ensuring that all operations invoked from the same client thread are executed on the server sequentially, using the same unit-of-order. This tends to provide best performance for fast, non-blocking operations.

        However, when invoking CPU-intensive or blocking operations, such as read- or write-through operations that access remote database or web service, for example, it may be very beneficial to allow the server to parallelize execution by passing AsyncNamedMap.OrderBy.none() configuration option to the async(AsyncNamedCache.Option...) method. Note, that in that case there are no guarantees for the order of execution.

        Returns:
        asynchronous wrapper for this NamedCache
      • async

        default AsyncNamedCache<K,​V> async​(AsyncNamedMap.Option... options)
        Return an asynchronous wrapper for this NamedCache.

        By default, the order of execution of asynchronous operation invoked on the returned AsyncNamedCache will be preserved by ensuring that all operations invoked from the same client thread are executed on the server sequentially, using the same unit-of-order. This tends to provide the best performance for fast, non-blocking operations.

        However, when invoking CPU-intensive or blocking operations, such as read- or write-through operations that access remote database or web service, for example, it may be very beneficial to allow the server to parallelize execution by passing AsyncNamedMap.OrderBy.none() configuration option to this method. Note, that in that case there are no guarantees for the order of execution.

        Specified by:
        async in interface NamedMap<K,​V>
        Parameters:
        options - the configuration options
        Returns:
        asynchronous wrapper for this NamedCache