public class SortedEvictionPolicy<K,V> extends Object implements EvictionPolicy<K,V>, SortedEvictionPolicyMBean, Externalizable
The eviction starts when the cache size becomes batchSize
elements greater than the maximum size.
batchSize
elements will be evicted in this case. The default batchSize
value is 1
.
Entries comparison based on Comparator
instance if provided.
Default Comparator
behaviour is use cache entries keys for comparison that imposes a requirement for keys
to implement Comparable
interface.
User defined comparator should implement Serializable
interface.
Constructor and Description |
---|
SortedEvictionPolicy()
Constructs sorted eviction policy with all defaults.
|
SortedEvictionPolicy(int max)
Constructs sorted eviction policy with maximum size.
|
SortedEvictionPolicy(int max,
Comparator<EvictableEntry<K,V>> comp)
Constructs sorted eviction policy with given maximum size and given entry comparator.
|
SortedEvictionPolicy(int max,
int batchSize,
Comparator<EvictableEntry<K,V>> comp)
Constructs sorted eviction policy with given maximum size, eviction batch size and entries comparator.
|
Modifier and Type | Method and Description |
---|---|
int |
getBatchSize()
Gets batch size.
|
int |
getCurrentSize()
Gets current size.
|
int |
getMaxSize()
Gets maximum allowed size of cache before entry will start getting evicted.
|
void |
onEntryAccessed(boolean rmv,
EvictableEntry<K,V> entry)
Callback for whenever entry is accessed.
|
void |
readExternal(ObjectInput in) |
Collection<EvictableEntry<K,V>> |
set()
Gets read-only view of backed set in proper order.
|
void |
setBatchSize(int batchSize)
Sets batch size.
|
void |
setMaxSize(int max)
Sets maximum allowed size of cache before entry will start getting evicted.
|
void |
writeExternal(ObjectOutput out) |
public SortedEvictionPolicy()
public SortedEvictionPolicy(int max)
max
- Maximum allowed size of cache before entry will start getting evicted.public SortedEvictionPolicy(int max, @Nullable Comparator<EvictableEntry<K,V>> comp)
max
- Maximum allowed size of cache before entry will start getting evicted.comp
- Entries comparator.public SortedEvictionPolicy(int max, int batchSize, @Nullable Comparator<EvictableEntry<K,V>> comp)
max
- Maximum allowed size of cache before entry will start getting evicted.batchSize
- Batch size.comp
- Entries comparator.public int getMaxSize()
getMaxSize
in interface SortedEvictionPolicyMBean
public void setMaxSize(int max)
setMaxSize
in interface SortedEvictionPolicyMBean
max
- Maximum allowed size of cache before entry will start getting evicted.public int getBatchSize()
getBatchSize
in interface SortedEvictionPolicyMBean
public void setBatchSize(int batchSize)
setBatchSize
in interface SortedEvictionPolicyMBean
batchSize
- Batch size.public int getCurrentSize()
getCurrentSize
in interface SortedEvictionPolicyMBean
public Collection<EvictableEntry<K,V>> set()
public void onEntryAccessed(boolean rmv, EvictableEntry<K,V> entry)
onEntryAccessed
in interface EvictionPolicy<K,V>
rmv
- True
if entry has been removed, false
otherwise.entry
- Accessed entry.public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
Follow @ApacheIgnite
Ignite Fabric : ver. 1.1.0-incubating Release Date : May 20 2015