|Managing Your Data in GemFire XD / Evicting Table Data from Memory|
GemFire XD keeps a table's data use under a specified level by removing the least recently used (LRU) data to free memory for new data. You configure table eviction settings based on entry count, the percentage of available heap, or the absolute memory usage of table data. You also configure the action that GemFire XD should take to evict data: destroy the data or overflow data to a disk store (creating a "overflow table").
When GemFire XD determines that adding or updating a row would take the table over the specified level, it overflows or removes as many older rows as it needed to make room. For entry count eviction, this means a one-to-one trade of an older row for the newer one.
For the memory settings, the number of older rows that need to be removed to make space depends entirely on the relative sizes of the older and newer entries. Eviction controllers monitor the table and memory use and, when the limit is reached, remove older entries to make way for new data. For JVM heap and off-heap memory percentage, the controller used is the GemFire XD resource manager, configured in conjunction with the JVM's garbage collector for optimum performance.
When eviction is enabled, GemFire XD manages table rows in a hash map-like structure where the primary key value is used as the key for all other column data in the row. When a row is evicted, the primary key value remains in memory while the remaining column data is evicted.To configure LRU eviction, see Create a Table with Eviction Settings and CREATE TABLE.After you configure eviction features, you can install a RowLoader and/or synchronous writer plug-in to access an external data source, effectively allowing GemFire XD to be used as a cache. For limitations of this capability, see Limitations of Eviction.