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 2006/01/22 00:06:22 UTC
svn commit: r371130 - in
/incubator/roller/trunk/src/org/roller/presentation/filters:
FeedCacheFilter.java IfModifiedFeedCacheFilter.java
Author: agilliland
Date: Sat Jan 21 15:06:16 2006
New Revision: 371130
URL: http://svn.apache.org/viewcvs?rev=371130&view=rev
Log:
fixing broken main feeds which were not being properly handled after adding the
lazy expiration code.
Modified:
incubator/roller/trunk/src/org/roller/presentation/filters/FeedCacheFilter.java
incubator/roller/trunk/src/org/roller/presentation/filters/IfModifiedFeedCacheFilter.java
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=371130&r1=371129&r2=371130&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/filters/FeedCacheFilter.java (original)
+++ incubator/roller/trunk/src/org/roller/presentation/filters/FeedCacheFilter.java Sat Jan 21 15:06:16 2006
@@ -60,8 +60,12 @@
// roller config properties that apply to this cache
private static final String CACHE_ID = "cache.feed";
+ // our cache of rendered feeds
private Cache mCache = null;
+ // the last time the main feeds were expired
+ private Date mainLastExpiredDate = new Date();
+
// for metrics
private double hits = 0;
private double misses = 0;
@@ -96,13 +100,20 @@
try {
ResponseContent respContent = null;
-
- // we need the last expiration time for the given weblog
long lastExpiration = 0;
- Date lastExpirationDate =
- (Date) CacheManager.getLastExpiredDate(feedRequest.getWeblogHandle());
- if(lastExpirationDate != null)
- lastExpiration = lastExpirationDate.getTime();
+
+ // first, we need to determine the last time the specified feed was expired.
+ // if this is a weblog specific feed then ask the CacheManager for
+ // the last expired time of the weblog. otherwise this is a main feed and we
+ // keep that last expired time ourselves
+ if(feedRequest.getWeblogHandle() != null) {
+ Date lastExpirationDate =
+ (Date) CacheManager.getLastExpiredDate(feedRequest.getWeblogHandle());
+ if(lastExpirationDate != null)
+ lastExpiration = lastExpirationDate.getTime();
+ } else {
+ lastExpiration = this.mainLastExpiredDate.getTime();
+ }
LazyExpiringCacheEntry entry =
(LazyExpiringCacheEntry) this.mCache.get(key);
@@ -225,36 +236,10 @@
mLogger.debug("invalidating website = "+website.getHandle());
- // we need to remove the following cached items if they exist
- // - the main feed
- // - the planet feed
- // - all weblog feeds
-
- /*
- Set removeSet = new HashSet();
-
- // TODO: it would be nice to be able to do this without iterating
- // over the entire cache key set
- String key = null;
-
- synchronized(mCache) {
- Iterator allKeys = this.mCache.keySet().iterator();
- while(allKeys.hasNext()) {
- key = (String) allKeys.next();
-
- if(key.startsWith("feedCache:main")) {
- removeSet.add(key);
- } else if(key.startsWith("feedCache:planet")) {
- removeSet.add(key);
- } else if(key.startsWith("feedCache:weblog/"+website.getHandle())) {
- removeSet.add(key);
- }
- }
+ // update our main feed last expiration date
+ synchronized(this) {
+ this.mainLastExpiredDate = new Date();
}
-
- this.mCache.remove(removeSet);
- this.purges += removeSet.size();
- */
}
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=371130&r1=371129&r2=371130&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/filters/IfModifiedFeedCacheFilter.java (original)
+++ incubator/roller/trunk/src/org/roller/presentation/filters/IfModifiedFeedCacheFilter.java Sat Jan 21 15:06:16 2006
@@ -65,8 +65,12 @@
// roller config properties that apply to this cache
private static final String CACHE_ID = "cache.ifmodified.feed";
+ // the cache of last updated times
private Cache mCache = null;
+ // the last time we expired our main feeds
+ private Date mainLastExpiredDate = new Date();
+
SimpleDateFormat dateFormatter =
new SimpleDateFormat("EEE MMM d HH:mm:ss z yyyy");
@@ -97,12 +101,20 @@
Date updateTime = null;
try {
- // we need the last expiration time for the given weblog
long lastExpiration = 0;
- Date lastExpirationDate =
- (Date) CacheManager.getLastExpiredDate(feedRequest.getWeblogHandle());
- if(lastExpirationDate != null)
- lastExpiration = lastExpirationDate.getTime();
+
+ // first, we need to determine the last time the specified feed was expired.
+ // if this is a weblog specific feed then ask the CacheManager for
+ // the last expired time of the weblog. otherwise this is a main feed and we
+ // keep that last expired time ourselves
+ if(feedRequest.getWeblogHandle() != null) {
+ Date lastExpirationDate =
+ (Date) CacheManager.getLastExpiredDate(feedRequest.getWeblogHandle());
+ if(lastExpirationDate != null)
+ lastExpiration = lastExpirationDate.getTime();
+ } else {
+ lastExpiration = this.mainLastExpiredDate.getTime();
+ }
LazyExpiringCacheEntry entry =
(LazyExpiringCacheEntry) this.mCache.get(key);
@@ -126,6 +138,9 @@
feedRequest.getWeblogCategory());
this.mCache.put(key, new LazyExpiringCacheEntry(updateTime));
+
+ } else {
+ this.mCache.put(key, new LazyExpiringCacheEntry(new Date()));
}
} else {
@@ -228,35 +243,10 @@
mLogger.debug("invalidating website = "+website.getHandle());
- // we need to remove the following cached items if they exist
- // - the main feed
- // - the planet feed
- // - all weblog feeds
-
- /*
- Set removeSet = new HashSet();
-
- // TODO: it would be nice to be able to do this without iterating
- // over the entire cache key set
- String key = null;
-
- synchronized(mCache) {
- Iterator allKeys = this.mCache.keySet().iterator();
- while(allKeys.hasNext()) {
- key = (String) allKeys.next();
-
- if(key.startsWith("ifmod:main")) {
- removeSet.add(key);
- } else if(key.startsWith("ifmod:planet")) {
- removeSet.add(key);
- } else if(key.startsWith("ifmod:weblog/"+website.getHandle())) {
- removeSet.add(key);
- }
- }
+ // update our main feed last expiration date
+ synchronized(this) {
+ this.mainLastExpiredDate = new Date();
}
-
- this.mCache.remove(removeSet);
- */
}