Class MapCacheStore<K,​V>

    • Constructor Detail

      • MapCacheStore

        public MapCacheStore​(Map<K,​V> map)
        Create a CacheStore that delegates to a Map.
        Parameters:
        map - the Map to use as the underlying store for this CacheStore
    • Method Detail

      • load

        public V load​(K key)
        Return the value associated with the specified key, or null if the key does not have an associated value in the underlying store.
        Specified by:
        load in interface CacheLoader<K,​V>
        Specified by:
        load in class AbstractCacheLoader<K,​V>
        Parameters:
        key - key whose associated value is to be returned
        Returns:
        the value associated with the specified key, or null if no value is available for that key
      • store

        public void store​(K key,
                          V value)
        Store the specified value under the specified key in the underlying store. This method is intended to support both key/value creation and value update for a specific key.
        Specified by:
        store in interface CacheStore<K,​V>
        Overrides:
        store in class AbstractCacheStore<K,​V>
        Parameters:
        key - key to store the value under
        value - value to be stored
      • storeAll

        public void storeAll​(Map<? extends K,​? extends V> mapEntries)
        Store the specified values under the specified keys in the underlying store. This method is intended to support both key/value creation and value update for the specified keys.
        Specified by:
        storeAll in interface CacheStore<K,​V>
        Parameters:
        mapEntries - a Map of any number of keys and values to store
      • erase

        public void erase​(K key)
        Remove the specified key from the underlying store if present.
        Specified by:
        erase in interface CacheStore<K,​V>
        Overrides:
        erase in class AbstractCacheStore<K,​V>
        Parameters:
        key - key to remove from the store
      • eraseAll

        public void eraseAll​(Collection<? extends K> colKeys)
        Remove the specified keys from the underlying store if present.
        Specified by:
        eraseAll in interface CacheStore<K,​V>
        Parameters:
        colKeys - keys whose mappings are being removed from the cache
      • keys

        public Iterator<K> keys()
        Iterate all keys in the underlying store.
        Specified by:
        keys in interface IterableCacheLoader<K,​V>
        Returns:
        a read-only iterator of the keys in the underlying store
      • getMap

        public Map<K,​V> getMap()
        Returns the Map that this CacheStore uses for its storage.
        Returns:
        the Map that this CacheStore uses
      • setMap

        protected void setMap​(Map<K,​V> map)
        Configures the Map that this CacheStore uses for its storage.
        Parameters:
        map - the Map that this CacheStore will use