Interface EvictableEntry<K,​V>

  • All Superinterfaces:
    javax.cache.Cache.Entry<K,​V>

    public interface EvictableEntry<K,​V>
    extends javax.cache.Cache.Entry<K,​V>
    Evictable cache entry passed into EvictionPolicy.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      <T> T addMeta​(T val)
      Adds a new metadata.
      boolean evict()
      Evicts entry associated with given key from cache.
      boolean isCached()
      Checks whether entry is currently present in cache or not.
      <T> T meta()
      Gets metadata added by eviction policy.
      <T> T putMetaIfAbsent​(T val)
      Adds given metadata value only if it was absent.
      <T> T removeMeta()
      Removes metadata by name.
      <T> boolean removeMeta​(T val)
      Removes metadata only if its current value is equal to val passed in.
      <T> boolean replaceMeta​(T curVal, T newVal)
      Replaces given metadata with new newVal value only if its current value is equal to curVal.
      int size()
      Returns entry size in bytes.
      • Methods inherited from interface javax.cache.Cache.Entry

        getKey, getValue, unwrap
    • Method Detail

      • evict

        boolean evict()
        Evicts entry associated with given key from cache. Note, that entry will be evicted only if it's not used (not participating in any locks or transactions).
        Returns:
        True if entry could be evicted, false otherwise.
      • isCached

        boolean isCached()
        Checks whether entry is currently present in cache or not. If entry is not in cache (e.g. has been removed) false is returned. In this case all operations on this entry will cause creation of a new entry in cache.
        Returns:
        True if entry is in cache, false otherwise.
      • size

        int size()
        Returns entry size in bytes.
        Returns:
        entry size in bytes.
      • meta

        @Nullable
        <T> T meta()
        Gets metadata added by eviction policy.
        Type Parameters:
        T - Type of the metadata value.
        Returns:
        Metadata value or null.
      • addMeta

        @Nullable
        <T> T addMeta​(T val)
        Adds a new metadata.
        Type Parameters:
        T - Type of the metadata value.
        Parameters:
        val - Metadata value.
        Returns:
        Metadata previously added, or null if there was none.
      • putMetaIfAbsent

        @Nullable
        <T> T putMetaIfAbsent​(T val)
        Adds given metadata value only if it was absent.
        Type Parameters:
        T - Type of the metadata value.
        Parameters:
        val - Value to add if it's not attached already.
        Returns:
        null if new value was put, or current value if put didn't happen.
      • replaceMeta

        <T> boolean replaceMeta​(T curVal,
                                T newVal)
        Replaces given metadata with new newVal value only if its current value is equal to curVal. Otherwise, it is no-op.
        Type Parameters:
        T - Type of the metadata value.
        Parameters:
        curVal - Current value to check.
        newVal - New value.
        Returns:
        true if replacement occurred, false otherwise.
      • removeMeta

        @Nullable
        <T> T removeMeta()
        Removes metadata by name.
        Type Parameters:
        T - Type of the metadata value.
        Returns:
        Value of removed metadata or null.
      • removeMeta

        <T> boolean removeMeta​(T val)
        Removes metadata only if its current value is equal to val passed in.
        Type Parameters:
        T - Type of the metadata value.
        Parameters:
        val - Value to compare.
        Returns:
        True if value was removed, false otherwise.