Class CacheEvictableEntryImpl<K,V>
- java.lang.Object
-
- org.apache.ignite.internal.processors.cache.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.
-
-
Field Summary
Fields Modifier and Type Field Description protected GridCacheEntryExcachedCached entry.
-
Constructor Summary
Constructors Modifier Constructor Description protectedCacheEvictableEntryImpl(GridCacheEntryEx cached)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> TaddMeta(T val)Adds a new metadata.booleanequals(Object obj)booleanevict()Evicts entry associated with given key from cache.KgetKey()VgetValue()inthashCode()booleanisCached()Checks whether entry is currently present in cache or not.<T> Tmeta()Gets metadata added by eviction policy.Vpeek()<T> TputMetaIfAbsent(T val)Adds given metadata value only if it was absent.<T> TremoveMeta()Removes metadata by name.<T> booleanremoveMeta(T val)Removes metadata only if its current value is equal tovalpassed in.<T> booleanreplaceMeta(T curVal, T newVal)Replaces given metadata with newnewValvalue only if its current value is equal tocurVal.intsize()Returns entry size in bytes.StringtoString()<T> Tunwrap(Class<T> clazz)
-
-
-
Field Detail
-
cached
@GridToStringInclude protected GridCacheEntryEx cached
Cached entry.
-
-
Constructor Detail
-
CacheEvictableEntryImpl
protected CacheEvictableEntryImpl(GridCacheEntryEx cached)
- Parameters:
cached- Cached entry.
-
-
Method Detail
-
getKey
public K getKey() throws IllegalStateException
- Specified by:
getKeyin interfacejavax.cache.Cache.Entry<K,V>- Throws:
IllegalStateException
-
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)falseis returned. In this case all operations on this entry will cause creation of a new entry in cache.- Specified by:
isCachedin interfaceEvictableEntry<K,V>- Returns:
Trueif entry is in cache,falseotherwise.
-
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:
evictin interfaceEvictableEntry<K,V>- Returns:
Trueif entry could be evicted,falseotherwise.
-
peek
@Nullable public V peek()
- Returns:
- Peeks value.
-
size
public int size()
Returns entry size in bytes.- Specified by:
sizein interfaceEvictableEntry<K,V>- Returns:
- entry size in bytes.
-
addMeta
@Nullable public <T> T addMeta(T val)
Adds a new metadata.- Specified by:
addMetain interfaceEvictableEntry<K,V>- Type Parameters:
T- Type of the metadata value.- Parameters:
val- Metadata value.- Returns:
- Metadata previously added, or
nullif there was none.
-
meta
@Nullable public <T> T meta()
Gets metadata added by eviction policy.- Specified by:
metain interfaceEvictableEntry<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:
removeMetain interfaceEvictableEntry<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 tovalpassed in.- Specified by:
removeMetain interfaceEvictableEntry<K,V>- Type Parameters:
T- Type of the metadata value.- Parameters:
val- Value to compare.- Returns:
Trueif value was removed,falseotherwise.
-
putMetaIfAbsent
@Nullable public <T> T putMetaIfAbsent(T val)
Adds given metadata value only if it was absent.- Specified by:
putMetaIfAbsentin interfaceEvictableEntry<K,V>- Type Parameters:
T- Type of the metadata value.- Parameters:
val- Value to add if it's not attached already.- Returns:
nullif 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 newnewValvalue only if its current value is equal tocurVal. Otherwise, it is no-op.- Specified by:
replaceMetain interfaceEvictableEntry<K,V>- Type Parameters:
T- Type of the metadata value.- Parameters:
curVal- Current value to check.newVal- New value.- Returns:
trueif replacement occurred,falseotherwise.
-
unwrap
public <T> T unwrap(Class<T> clazz)
-
-