Skip to content
This repository has been archived by the owner on Feb 15, 2023. It is now read-only.

Commit

Permalink
instrumenting to track lens caching
Browse files Browse the repository at this point in the history
  • Loading branch information
zepheiryan committed Oct 15, 2011
1 parent e0b5bb0 commit e6e0975
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
public class ScriptableBackstage extends BackstageScriptableObject {
private static final long serialVersionUID = -6840851588510351185L;

@SuppressWarnings("unused")
protected static Logger _logger = LoggerFactory.getLogger("backstage.scriptable");

public static String getName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,13 @@ public void configure(Scriptable config, BackChannel backChannel) {
}

public Scriptable generateLens(String itemID) {
_logger.debug("> generateLens");
String key = "lens-rendering:" + itemID;
_logger.debug("itemID: " + key);
Scriptable result = (Scriptable)
getDatabase().cacheAndRun(key, new LensRenderingCacheableQuery(itemID));

_logger.debug("< generateLens");
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,15 @@ public void discardCacheableQuery(String key) {
}

public Object cacheAndRun(String key, CacheableQuery cq) {
_logger.debug("> cacheAndRun");
if (_cacheableQueries.containsKey(key)) {
_logger.debug("cached: " + key);
cq = _cacheableQueries.get(key); // use the old one
} else {
_logger.debug("not cached");
_cacheableQueries.put(key, cq);
}

_logger.debug("< cacheAndRun");
return cq.run();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@ public TileView(Context context, String id) {

@Override
public Scriptable getComponentState() {
_logger.debug("> getComponentState");
TupleQueryBuilder builder = new TupleQueryBuilder();
Var itemVar = getCollection().getRestrictedItems(builder, null);

String key = "tile-view-rendering:" + builder.getStringSerialization();
_logger.debug("component: " + key);
Scriptable result = (Scriptable)
_context.getDatabase().cacheAndRun(key, new ViewRenderingCacheableQuery(builder, itemVar));

_logger.debug("< getComponentState");
return result;
}

Expand All @@ -48,6 +51,7 @@ protected class ViewRenderingCacheableQuery extends CacheableQuery {

@Override
protected Object internalRun() {
_logger.debug("> internalRun");
Database database = _context.getDatabase();

DefaultScriptableObject result = new DefaultScriptableObject();
Expand Down Expand Up @@ -90,6 +94,7 @@ protected Object internalRun() {
result.put("items", result, itemIDs.toArray());
result.put("lenses", result, lenses.toArray());

_logger.debug("< internalRun");
return result;
}
}
Expand Down

0 comments on commit e6e0975

Please sign in to comment.