Class CacheEvictableEntryImpl<K,​V>

  • All Implemented Interfaces:
    javax.cache.Cache.Entry<K,​V>, EvictableEntry<K,​V>

    public class CacheEvictableEntryImpl<K,​V>
    extends Object
    implements EvictableEntry<K,​V>
    Entry wrapper that never obscures obsolete entries from user.
    • Constructor Detail

      • CacheEvictableEntryImpl

        protected CacheEvictableEntryImpl​(GridCacheEntryEx cached)
        Parameters:
        cached - Cached entry.
    • Method Detail

      • isCached

        public 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.
        Specified by:
        isCached in interface EvictableEntry<K,​V>
        Returns:
        True if entry is in cache, false otherwise.
      • evict

        public 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).
        Specified by:
        evict in interface EvictableEntry<K,​V>
        Returns:
        True if entry could be evicted, false otherwise.
      • peek

        @Nullable
        public V peek()
        Returns:
        Peeks value.
      • size

        public int size()
        Returns entry size in bytes.
        Specified by:
        size in interface EvictableEntry<K,​V>
        Returns:
        entry size in bytes.
      • getValue

        public V getValue()
        Specified by:
        getValue in interface javax.cache.Cache.Entry<K,​V>
      • addMeta

        @Nullable
        public <T> T addMeta​(T val)
        Adds a new metadata.
        Specified by:
        addMeta in interface EvictableEntry<K,​V>
        Type Parameters:
        T - Type of the metadata value.
        Parameters:
        val - Metadata value.
        Returns:
        Metadata previously added, or null if there was none.
      • meta

        @Nullable
        public <T> T meta()
        Gets metadata added by eviction policy.
        Specified by:
        meta in interface EvictableEntry<K,​V>
        Type Parameters:
        T - Type of the metadata value.
        Returns:
        Metadata value or null.
      • removeMeta

        @Nullable
        public <T> T removeMeta()
        Removes metadata by name.
        Specified by:
        removeMeta in interface EvictableEntry<K,​V>
        Type Parameters:
        T - Type of the metadata value.
        Returns:
        Value of removed metadata or null.
      • removeMeta

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

        @Nullable
        public <T> T putMetaIfAbsent​(T val)
        Adds given metadata value only if it was absent.
        Specified by:
        putMetaIfAbsent in interface EvictableEntry<K,​V>
        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

        public <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.
        Specified by:
        replaceMeta in interface EvictableEntry<K,​V>
        Type Parameters:
        T - Type of the metadata value.
        Parameters:
        curVal - Current value to check.
        newVal - New value.
        Returns:
        true if replacement occurred, false otherwise.
      • unwrap

        public <T> T unwrap​(Class<T> clazz)
        Specified by:
        unwrap in interface javax.cache.Cache.Entry<K,​V>
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object