Interface Cache

    • Method Detail

      • put

        void put​(String id,
                 Object value)
        Adds or replaces a value in the cache.
        Parameters:
        id - The object id
        value - The value to cache
      • get

        <T> T get​(String id,
                  Function<? super String,​T> mappingFunction)
        Returns the value associated with the given id. If there is no association, the mapping function is used to calculate a value. This value will be stored in the cache.
        Type Parameters:
        T - the type of object to return from the cache
        Parameters:
        id - The object id
        mappingFunction - The function to compute a value if the cache is not in the cache
        Returns:
        The value associated with given id
      • getIfPresent

        <T> T getIfPresent​(String id)
        Returns the value associated with the given id if it exists in the cache. If there is no association, null is returned.
        Type Parameters:
        T - the type of object to return from the cache
        Parameters:
        id - The object id
        Returns:
        The value associated with given id
      • invalidate

        void invalidate​(String id)
        Invalidates the cache entry mapped to given id.
      • invalidateAll

        void invalidateAll()
        Invalidates all cache entries.