Package io.grpc.rls

Interface LruCache<K,​V>

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      V cache​(K key, V value)
      Populates a cache entry.
      void close()
      Closes underlying resources.
      int estimatedSize()
      Returns the estimated number of entry of the cache.
      boolean hasCacheEntry​(K key)
      Returns true if given key is cached.
      V invalidate​(K key)
      Invalidates an entry for given key if exists.
      void invalidateAll()
      Invalidates cache entries for all keys.
      V read​(K key)
      Returns cached value for given key if exists, otherwise null.
    • Method Detail

      • cache

        @Nullable
        V cache​(K key,
                V value)
        Populates a cache entry. If the cache entry for given key already exists, the value will be replaced to the new value.
        Returns:
        the previous value associated with key, otherwise null
      • read

        @Nullable
        @CheckReturnValue
        V read​(K key)
        Returns cached value for given key if exists, otherwise null. This operation doesn't return already expired cache entry.
      • hasCacheEntry

        @CheckReturnValue
        boolean hasCacheEntry​(K key)
        Returns true if given key is cached.
      • estimatedSize

        @CheckReturnValue
        int estimatedSize()
        Returns the estimated number of entry of the cache. Note that the size can be larger than its true size, because there might be already expired cache.
      • close

        void close()
        Closes underlying resources.