type=theType;
selector=theSelector;
}
- public boolean equals(CacheKey aCacheKey){
- if (aCacheKey.type.equals(type) && aCacheKey.selector.equals(selector))
+
+ public int hashCode(){
+ return type.hashCode()+selector.hashCode();
+ }
+
+ public boolean equals(Object aCacheKey){
+ if (!(aCacheKey instanceof CacheKey))
+ return false;
+ if (((CacheKey) aCacheKey).type.equals(type) && ((CacheKey) aCacheKey).selector.equals(selector))
return true;
else
return false;
\r
public boolean hasObject(CacheKey aCacheKey) {\r
synchronized (cache) {\r
+ logger.info("MRUCache was this big : "+ mruList.size());\r
return cache.containsKey(aCacheKey);\r
}\r
}\r
if (! hasObject(aCacheKey)){\r
// add to the cache\r
cache.put(aCacheKey,data);\r
- if (mruList.size() > cacheMaxItems){\r
+ if (mruList.size() >= cacheMaxItems){\r
removeObject((CacheKey) mruList.getLast());\r
}\r
}\r
import mir.util.StringRoutines;\r
import mircoders.entity.EntityComment;\r
import mircoders.entity.EntityContent;\r
-//import mircoders.global.CacheKey;\r
+import mircoders.global.CacheKey;\r
import mircoders.global.MirGlobal;\r
import mircoders.media.*;\r
import mircoders.media.UnsupportedMediaFormatExc;\r
* open-postings to the newswire\r
*\r
* @author mir-coders group\r
- * @version $Id: ServletModuleOpenIndy.java,v 1.76 2003/04/18 14:54:54 john Exp $\r
+ * @version $Id: ServletModuleOpenIndy.java,v 1.77 2003/04/18 15:37:29 john Exp $\r
*\r
*/\r
\r
\r
String cacheType="pdf";\r
\r
- String theCacheKey = cacheType+":"+cacheSelector;\r
+ CacheKey theCacheKey = new CacheKey(cacheType,cacheSelector);\r
\r
byte[] thePDF;\r
\r
if (MirGlobal.mruCache().hasObject(theCacheKey)){\r
- logger.warn("fetching pdf from cache");\r
+ logger.info("fetching pdf from cache");\r
thePDF = (byte[]) MirGlobal.mruCache().getObject(theCacheKey);\r
}\r
else {\r
- logger.warn("generating pdf and caching it");\r
+ logger.info("generating pdf and caching it");\r
ByteArrayOutputStream out = new ByteArrayOutputStream();\r
PDFGenerator pdfMaker = new PDFGenerator(out);\r
\r
res.getOutputStream().write(thePDF);\r
res.getOutputStream().flush();\r
String elapsedtime=(new Long(System.currentTimeMillis()-starttime)).toString();\r
- logger.warn("pdf retireval took "+elapsedtime + " milliseconds" );\r
+ logger.info("pdf retireval took "+elapsedtime + " milliseconds" );\r
\r
}\r
else {\r