You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by ag...@apache.org on 2005/12/01 22:47:58 UTC
svn commit: r351488 - in
/incubator/roller/trunk/src/org/roller/presentation: cache/ filters/
Author: agilliland
Date: Thu Dec 1 13:47:53 2005
New Revision: 351488
URL: http://svn.apache.org/viewcvs?rev=351488&view=rev
Log:
- allow the cache manager to clear cache handlers.
- added some additional metrics to the current handlers.
Modified:
incubator/roller/trunk/src/org/roller/presentation/cache/CacheHandler.java
incubator/roller/trunk/src/org/roller/presentation/cache/CacheManager.java
incubator/roller/trunk/src/org/roller/presentation/filters/FeedCacheFilter.java
incubator/roller/trunk/src/org/roller/presentation/filters/IfModifiedFeedCacheFilter.java
incubator/roller/trunk/src/org/roller/presentation/filters/MainPageCacheFilter.java
incubator/roller/trunk/src/org/roller/presentation/filters/WeblogPageCacheFilter.java
Modified: incubator/roller/trunk/src/org/roller/presentation/cache/CacheHandler.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/cache/CacheHandler.java?rev=351488&r1=351487&r2=351488&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/cache/CacheHandler.java (original)
+++ incubator/roller/trunk/src/org/roller/presentation/cache/CacheHandler.java Thu Dec 1 13:47:53 2005
@@ -48,6 +48,8 @@
public void invalidate(WeblogTemplate template);
+ public void clear();
+
public Map getStats();
}
Modified: incubator/roller/trunk/src/org/roller/presentation/cache/CacheManager.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/cache/CacheManager.java?rev=351488&r1=351487&r2=351488&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/cache/CacheManager.java (original)
+++ incubator/roller/trunk/src/org/roller/presentation/cache/CacheManager.java Thu Dec 1 13:47:53 2005
@@ -286,6 +286,40 @@
/**
+ * Flush the entire cache system.
+ */
+ public static void clear() {
+
+ // loop through all handlers and trigger a clear
+ CacheHandler handler = null;
+ Iterator handlers = cacheHandlers.iterator();
+ while(handlers.hasNext()) {
+ handler = (CacheHandler) handlers.next();
+
+ handler.clear();
+ }
+ }
+
+
+ /**
+ * Flush a single cache handler.
+ */
+ public static void clear(String handlerClass) {
+
+ // loop through all handlers to find the one we want
+ CacheHandler handler = null;
+ Iterator handlers = cacheHandlers.iterator();
+ while(handlers.hasNext()) {
+ handler = (CacheHandler) handlers.next();
+
+ if(handler.getClass().getName().equals(handlerClass)) {
+ handler.clear();
+ }
+ }
+ }
+
+
+ /**
* Compile stats from all registered handlers.
*
* This is basically a hacky version of instrumentation which is being
Modified: incubator/roller/trunk/src/org/roller/presentation/filters/FeedCacheFilter.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/filters/FeedCacheFilter.java?rev=351488&r1=351487&r2=351488&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/filters/FeedCacheFilter.java (original)
+++ incubator/roller/trunk/src/org/roller/presentation/filters/FeedCacheFilter.java Thu Dec 1 13:47:53 2005
@@ -273,6 +273,19 @@
/**
+ * Clear the entire cache.
+ */
+ public void clear() {
+ mLogger.info("Clearing cache");
+ this.mFeedCache.clear();
+ this.startTime = new Date();
+ this.hits = 0;
+ this.misses = 0;
+ this.purges = 0;
+ }
+
+
+ /**
* A weblog template has changed.
*/
public void invalidate(WeblogTemplate template) {
@@ -283,6 +296,7 @@
public Map getStats() {
Map stats = new HashMap();
+ stats.put("cacheType", this.mFeedCache.getClass().getName());
stats.put("startTime", this.startTime);
stats.put("hits", new Double(this.hits));
stats.put("misses", new Double(this.misses));
Modified: incubator/roller/trunk/src/org/roller/presentation/filters/IfModifiedFeedCacheFilter.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/filters/IfModifiedFeedCacheFilter.java?rev=351488&r1=351487&r2=351488&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/filters/IfModifiedFeedCacheFilter.java (original)
+++ incubator/roller/trunk/src/org/roller/presentation/filters/IfModifiedFeedCacheFilter.java Thu Dec 1 13:47:53 2005
@@ -291,6 +291,15 @@
}
+ /**
+ * Clear the entire cache.
+ */
+ public void clear() {
+ mLogger.info("Clearing cache");
+ this.mCache.clear();
+ }
+
+
public Map getStats() {
Map stats = new HashMap();
Modified: incubator/roller/trunk/src/org/roller/presentation/filters/MainPageCacheFilter.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/filters/MainPageCacheFilter.java?rev=351488&r1=351487&r2=351488&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/filters/MainPageCacheFilter.java (original)
+++ incubator/roller/trunk/src/org/roller/presentation/filters/MainPageCacheFilter.java Thu Dec 1 13:47:53 2005
@@ -57,6 +57,7 @@
private double hits = 0;
private double misses = 0;
private double purges = 0;
+ private double skips = 0;
private Date startTime = new Date();
@@ -132,6 +133,7 @@
this.mPageCache.put(key, rc);
} else {
mLogger.debug("SKIPPED "+key);
+ this.skips++;
}
} else {
mLogger.error("Display exception "+key);
@@ -235,13 +237,29 @@
}
+ /**
+ * Clear the entire cache.
+ */
+ public void clear() {
+ mLogger.info("Clearing cache");
+ this.mPageCache.clear();
+ this.startTime = new Date();
+ this.hits = 0;
+ this.misses = 0;
+ this.purges = 0;
+ this.skips = 0;
+ }
+
+
public Map getStats() {
Map stats = new HashMap();
+ stats.put("cacheType", this.mPageCache.getClass().getName());
stats.put("startTime", this.startTime);
stats.put("hits", new Double(this.hits));
stats.put("misses", new Double(this.misses));
stats.put("purges", new Double(this.purges));
+ stats.put("skips", new Double(this.skips));
// calculate efficiency
if((misses - purges) > 0) {
Modified: incubator/roller/trunk/src/org/roller/presentation/filters/WeblogPageCacheFilter.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/filters/WeblogPageCacheFilter.java?rev=351488&r1=351487&r2=351488&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/filters/WeblogPageCacheFilter.java (original)
+++ incubator/roller/trunk/src/org/roller/presentation/filters/WeblogPageCacheFilter.java Thu Dec 1 13:47:53 2005
@@ -58,6 +58,7 @@
private double hits = 0;
private double misses = 0;
private double purges = 0;
+ private double skips = 0;
private Date startTime = new Date();
@@ -112,6 +113,7 @@
this.mPageCache.put(key, rc);
} else {
mLogger.debug("SKIPPED "+key);
+ this.skips++;
}
} else {
mLogger.error("Display exception "+key);
@@ -327,13 +329,29 @@
}
+ /**
+ * Clear the entire cache.
+ */
+ public void clear() {
+ mLogger.info("Clearing cache");
+ this.mPageCache.clear();
+ this.startTime = new Date();
+ this.hits = 0;
+ this.misses = 0;
+ this.purges = 0;
+ this.skips = 0;
+ }
+
+
public Map getStats() {
Map stats = new HashMap();
+ stats.put("cacheType", this.mPageCache.getClass().getName());
stats.put("startTime", this.startTime);
stats.put("hits", new Double(this.hits));
stats.put("misses", new Double(this.misses));
stats.put("purges", new Double(this.purges));
+ stats.put("skips", new Double(this.skips));
// calculate efficiency
if((misses - purges) > 0) {