org.apache.ignite.cache.eviction.random

## Class RandomEvictionPolicy<K,V>

- java.lang.Object
- - org.apache.ignite.cache.eviction.random.RandomEvictionPolicy<K,V>

All Implemented Interfaces:
  Externalizable, Serializable, EvictionPolicy<K,V>, RandomEvictionPolicyMBean

    public class RandomEvictionPolicy<K,V>
    extends Object
    implements EvictionPolicy<K,V>, RandomEvictionPolicyMBean, Externalizable

Cache eviction policy which will select random cache entry for eviction if cache size exceeds the `getMaxSize()` parameter. This implementation is extremely light weight, lock-free, and does not create any data structures to maintain any order for eviction.

Random eviction will provide the best performance over any key set in which every key has the same probability of being accessed.

See Also:
  Serialized Form

### Constructor Summary

Constructors
Constructor and Description
`RandomEvictionPolicy()` Constructs random eviction policy with all defaults.
`RandomEvictionPolicy(int max)` Constructs random eviction policy with maximum size.

### Method Summary

Methods
`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)`
`void` `setMaxSize(int max)` Sets maximum allowed size of cache before entry will start getting evicted.
`String` `toString()`
`void` `writeExternal(ObjectOutput out)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### RandomEvictionPolicy

    public RandomEvictionPolicy()

Constructs random eviction policy with all defaults.

#### RandomEvictionPolicy

    public RandomEvictionPolicy(int max)

Constructs random eviction policy with maximum size.

Parameters:
  `max` - Maximum allowed size of cache before entry will start getting evicted.

### Method Detail

#### getMaxSize

    public int getMaxSize()

Gets maximum allowed size of cache before entry will start getting evicted.

Specified by:
  `getMaxSize` in interface `RandomEvictionPolicyMBean`
Returns:
  Maximum allowed size of cache before entry will start getting evicted.

#### setMaxSize

    public void setMaxSize(int max)

Sets maximum allowed size of cache before entry will start getting evicted.

Specified by:
  `setMaxSize` in interface `RandomEvictionPolicyMBean`
Parameters:
  `max` - Maximum allowed size of cache before entry will start getting evicted.

#### onEntryAccessed

    public void onEntryAccessed(boolean rmv,
                       EvictableEntry<K,V> entry)

Callback for whenever entry is accessed.

Specified by:
  `onEntryAccessed` in interface `EvictionPolicy<K,V>`
Parameters:
  `rmv` - `True` if entry has been removed, `false` otherwise.
  `entry` - Accessed entry.

#### writeExternal

    public void writeExternal(ObjectOutput out)
                       throws IOException

Specified by:
  `writeExternal` in interface `Externalizable`
Throws:
  `IOException`

#### readExternal

    public void readExternal(ObjectInput in)
                      throws IOException,
                             ClassNotFoundException

Specified by:
  `readExternal` in interface `Externalizable`
Throws:
  `IOException`
  `ClassNotFoundException`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.0.0
Release Date | : March 31 2015