public abstract class ReleaseStrategy extends Object
This class is the base for all cache release strategies. You should extend this to create your own. It will contain a number of usefull utility methods to analyze query objecs and cached search results. Feel free to add those In case you miss one developing your own strategies.
| Modifier and Type | Class and Description |
|---|---|
static class |
ReleaseStrategy.StrategyResult |
protected static class |
ReleaseStrategy.Timer
Deprecated.
The only thing what this does is knowing how to subtract, which is really not so
difficult or verbose by itself
|
| Constructor and Description |
|---|
ReleaseStrategy() |
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
protected abstract boolean |
doEvaluate(NodeEvent event,
SearchQuery query,
List<MMObjectNode> cachedResult)
implement this method to create your own strategy.
|
protected abstract boolean |
doEvaluate(RelationEvent event,
SearchQuery query,
List<MMObjectNode> cachedResult)
implement this method to create your own strategy.
|
boolean |
equals(Object ob) |
ReleaseStrategy.StrategyResult |
evaluate(NodeEvent event,
SearchQuery query,
List<MMObjectNode> cachedResult)
This method checks if evaluation should happen (active), keeps the time
of the operation and updates the statistics.
|
ReleaseStrategy.StrategyResult |
evaluate(RelationEvent event,
SearchQuery query,
List<MMObjectNode> cachedResult) |
int |
getAvgEvaluationTimeInMilis() |
protected static List<Constraint> |
getConstraintsForField(String fieldName,
MMObjectBuilder builder,
Constraint constraint,
SearchQuery query)
utility for specializations: get all the constraints in the query that apply to
a certain field
TODO MM: This method is used like this:
if(getConstraintsForField(fieldName, eventBuilder, constraint, query).size() > 0){ return false;}
IOW, only the size of the return list is used, and then even whether it is 0 or not. |
abstract String |
getDescription() |
abstract String |
getName() |
protected static List<SortOrder> |
getSortordersForField(String fieldName,
MMObjectBuilder builder,
List<SortOrder> sortOrders,
SearchQuery query)
utility for specializations: get all the sortorders in the query that apply to
a certain field
TODO MM: See remark at
getConstraintsForField(java.lang.String, org.mmbase.module.core.MMObjectBuilder, org.mmbase.storage.search.Constraint, org.mmbase.storage.search.SearchQuery) |
int |
getTotalEvaluated() |
long |
getTotalEvaluationTimeMillis() |
int |
getTotalPreserved() |
int |
hashCode() |
boolean |
isEnabled() |
void |
setEnabled(boolean newStatus) |
String |
toString() |
public abstract String getName()
public abstract String getDescription()
public int getAvgEvaluationTimeInMilis()
public long getTotalEvaluationTimeMillis()
public final ReleaseStrategy.StrategyResult evaluate(NodeEvent event, SearchQuery query, List<MMObjectNode> cachedResult)
doEvaluate(NodeEvent event, SearchQuery query, List cachedResult).public final ReleaseStrategy.StrategyResult evaluate(RelationEvent event, SearchQuery query, List<MMObjectNode> cachedResult)
public int getTotalPreserved()
public int getTotalEvaluated()
protected abstract boolean doEvaluate(NodeEvent event, SearchQuery query, List<MMObjectNode> cachedResult)
event - a node eventquery - cachedResult - protected abstract boolean doEvaluate(RelationEvent event, SearchQuery query, List<MMObjectNode> cachedResult)
event - a relation eventquery - cachedResult - public void setEnabled(boolean newStatus)
public boolean isEnabled()
public void clear()
protected static List<Constraint> getConstraintsForField(String fieldName, MMObjectBuilder builder, Constraint constraint, SearchQuery query)
if(getConstraintsForField(fieldName, eventBuilder, constraint, query).size() > 0){ return false;}
IOW, only the size of the return list is used, and then even whether it is 0 or not. I think it is a waste to construct a complete new list, only for that.
Perhaps the method should return an Iterator?, and can be used with only 'hasNext()', constructing a longer list then necessary is avoided then.fieldName - builder - constraint - query - protected static List<SortOrder> getSortordersForField(String fieldName, MMObjectBuilder builder, List<SortOrder> sortOrders, SearchQuery query)
getConstraintsForField(java.lang.String, org.mmbase.module.core.MMObjectBuilder, org.mmbase.storage.search.Constraint, org.mmbase.storage.search.SearchQuery)fieldName - builder - sortOrders - query - MMBase 1.9-SNAPSHOT - ${javadoctimestamp}