Actually evict/invalidate nodes when invalidating child nodes via id/accessname,

if they are present in the cache.
Fixes bug 190, http://helma.org/bugs/show_bug.cgi?id=190
This commit is contained in:
hns 2003-01-13 11:59:57 +00:00
parent 63bcb750a3
commit f6b2909aad
3 changed files with 23 additions and 5 deletions

View file

@ -435,9 +435,9 @@ public final class Node implements INode, Serializable {
Relation rel = getDbMapping ().getSubnodeRelation (); Relation rel = getDbMapping ().getSubnodeRelation ();
if (rel != null) { if (rel != null) {
if (rel.usesPrimaryKey()) { if (rel.usesPrimaryKey()) {
nmgr.evictKey (new DbKey (getDbMapping().getSubnodeMapping(), key)); nmgr.evictNodeByKey (new DbKey (getDbMapping().getSubnodeMapping(), key));
} else { } else {
nmgr.evictKey (new SyntheticKey (getKey(), key)); nmgr.evictNodeByKey (new SyntheticKey (getKey(), key));
} }
} }
} }

View file

@ -360,8 +360,8 @@ public final class NodeManager {
} }
/** /**
* Remove a node from the node cache. If at a later time it is accessed again, it will be * Remove a node from the node cache. If at a later time it is accessed again,
* refetched from the database. * it will be refetched from the database.
*/ */
public void evictNode (Node node) { public void evictNode (Node node) {
node.setState (INode.INVALID); node.setState (INode.INVALID);
@ -369,7 +369,21 @@ public final class NodeManager {
} }
/** /**
* Used when a key stops being valid for a node. * Remove a node from the node cache. If at a later time it is accessed again,
* it will be refetched from the database.
*/
public void evictNodeByKey (Key key) {
Node n = (Node) cache.remove (key);
if (n != null) {
n.setState (INode.INVALID);
if (!(key instanceof DbKey))
cache.remove (n.getKey ());
}
}
/**
* Used when a key stops being valid for a node. The cached node itself
* remains valid, if it is present in the cache by other keys.
*/ */
public void evictKey (Key key) { public void evictKey (Key key) {
cache.remove (key); cache.remove (key);

View file

@ -110,6 +110,10 @@ import java.util.Vector;
nmgr.evictNode (node); nmgr.evictNode (node);
} }
public void evictNodeByKey (Key key) {
nmgr.evictNodeByKey (key);
}
public void evictKey (Key key) { public void evictKey (Key key) {
nmgr.evictKey (key); nmgr.evictKey (key);
} }