com.ibm.storage.clientlibrary

Class InProcessCache<K,V>

    • Constructor Detail

      • InProcessCache

        public InProcessCache(long maxObjects,
                              long defaultLifespan)
        Constructor
        Parameters:
        maxObjects - maximum number of objects which can be stored before replacement starts
        defaultLifespan - Default life time in milliseconds for cached objects
    • Method Detail

      • clear

        public void clear()
        delete all key-value pairs from the cache
        Specified by:
        clear in interface Cache<K,V>
      • delete

        public void delete(K key)
        delete a key-value pair from the cache
        Specified by:
        delete in interface Cache<K,V>
        Parameters:
        key - key corresponding to value
      • deleteAll

        public void deleteAll(List<K> keys)
        delete one or more key-value pairs from the cache
        Specified by:
        deleteAll in interface Cache<K,V>
        Parameters:
        keys - iterable data structure containing the keys to delete
      • get

        public V get(K key)
        look up a value in the cache
        Specified by:
        get in interface Cache<K,V>
        Parameters:
        key - key corresponding to value
        Returns:
        value corresponding to key, null if key is not in cache or if value is expired
      • getAll

        public Map<K,V> getAll(List<K> keys)
        look up one or more values in the cache. Don't return expired values.
        Specified by:
        getAll in interface Cache<K,V>
        Parameters:
        keys - iterable data structure containing the keys to look up
        Returns:
        map containing key-value pairs corresponding to unexpired data in the cache
      • getCacheEntry

        public CacheEntry<V> getCacheEntry(K key)
        look up a CacheEntry in the cache. The CacheEntry may correspond to expired data. This method can be used to revalidate cached objects whose expiration times have passed
        Specified by:
        getCacheEntry in interface Cache<K,V>
        Parameters:
        key - key corresponding to value
        Returns:
        value corresponding to key (may be expired), null if key is not in cache
      • printCacheEntry

        public String printCacheEntry(K key)
        Return string representing a cache entry corresponding to a key (or indicate if the key is not in the cache).
        Parameters:
        key - key corresponding to value
        Returns:
        string containing output
      • put

        public void put(K key,
                        V value)
        cache a key-value pair
        Specified by:
        put in interface Cache<K,V>
        Parameters:
        key - key associated with value
        value - value associated with key
      • put

        public void put(K key,
                        V value,
                        long lifetime)
        cache a key-value pair
        Specified by:
        put in interface CacheWithLifetimes<K,V>
        Parameters:
        key - key associated with value
        value - value associated with key
        lifetime - lifetime in milliseconds associated with data
      • putAll

        public void putAll(Map<K,V> map)
        cache one or more key-value pairs
        Specified by:
        putAll in interface Cache<K,V>
        Parameters:
        map - map containing key-value pairs to cache
      • putAll

        public void putAll(Map<K,V> map,
                           long lifetime)
        cache one or more key-value pairs
        Specified by:
        putAll in interface CacheWithLifetimes<K,V>
        Parameters:
        map - map containing key-value pairs to cache
        lifetime - lifetime in milliseconds associated with each key-value pair
      • size

        public long size()
        Return number of objects in cache
        Specified by:
        size in interface Cache<K,V>
        Returns:
        number of objects in cache
      • toString

        public String toString()
        Return contents of entire cache in a string
        Overrides:
        toString in class Object
        Returns:
        string containing output

Copyright © 2015. All rights reserved.