JBoss.org Community Documentation
Nodes marked as resident (using
Node.setResident()
API) will be ignored by the eviction policies both when checking whether to trigger
the eviction and when proceeding with the actual eviction of nodes. E.g. if a region is configured to have a
maximum of 10 nodes, resident nodes won't be
counted when deciding whether to evict nodes in that region. In addition, resident nodes will not be
considered for eviction when the region's eviction
threshold is reached.
In order to mark a node as resident the
Node.setResident()
API should be used. By default, the newly created nodes are not resident.
The
resident
attribute of a node is neither replicated, persisted nor transaction-aware.
A sample use case for resident nodes would be ensuring "path" nodes don't add "noise" to an eviction policy. E.g.,:
...
Map lotsOfData = generateData();
cache.put("/a/b/c", lotsOfData);
cache.getRoot().getChild("/a").setResident(true);
cache.getRoot().getChild("/a/b").setResident(true);
...
In this example, the nodes
/a
and
/a/b
are paths which exist solely to
support the existence of node
/a/b/c
and don't hold any data themselves. As such, they are
good candidates for being marked as resident. This would lead to better memory management as no eviction
events would be
generated when accessing
/a
and/a/b
.
N.B. when adding attributes to a resident node, e.g.
cache.put("/a", "k", "v")
in the above example, it would make sense to mark the nodes
as non-resident again and let them be considered for eviction..