[hmath-commits] org.hmath.server/WEB-INF/src/org/hartmath/server/cache LRUCache.java,NONE,1.1 DummyC
Status: Pre-Alpha
Brought to you by:
jsurfer
Update of /cvsroot/hmath/org.hmath.server/WEB-INF/src/org/hartmath/server/cache In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25118/WEB-INF/src/org/hartmath/server/cache Modified Files: DummyCachedPageGenerator.java CachedPage.java CachedPageGenerator.java ICachedPageGenerator.java Added Files: LRUCache.java Log Message: Improved cache; fixed "table of content" bug Index: ICachedPageGenerator.java =================================================================== RCS file: /cvsroot/hmath/org.hmath.server/WEB-INF/src/org/hartmath/server/cache/ICachedPageGenerator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ICachedPageGenerator.java 2 May 2004 12:43:06 -0000 1.1 --- ICachedPageGenerator.java 2 May 2004 17:34:10 -0000 1.2 *************** *** 1,2 **** --- 1,19 ---- + /* + * This file is part of the "HMath MathML BLOG/Wiki Engine". + * + * Copyright (c) 2004 Klaus Hartlage All Rights Reserved. + * + * Please visit http://www.hmath.org/ for updates and contact. + * + * --LICENSE NOTICE-- This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser + * General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any + * later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free + * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --LICENSE NOTICE-- + */ package org.hartmath.server.cache; Index: DummyCachedPageGenerator.java =================================================================== RCS file: /cvsroot/hmath/org.hmath.server/WEB-INF/src/org/hartmath/server/cache/DummyCachedPageGenerator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DummyCachedPageGenerator.java 2 May 2004 12:43:06 -0000 1.1 --- DummyCachedPageGenerator.java 2 May 2004 17:34:10 -0000 1.2 *************** *** 1,2 **** --- 1,19 ---- + /* + * This file is part of the "HMath MathML BLOG/Wiki Engine". + * + * Copyright (c) 2004 Klaus Hartlage All Rights Reserved. + * + * Please visit http://www.hmath.org/ for updates and contact. + * + * --LICENSE NOTICE-- This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser + * General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any + * later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free + * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --LICENSE NOTICE-- + */ package org.hartmath.server.cache; Index: CachedPage.java =================================================================== RCS file: /cvsroot/hmath/org.hmath.server/WEB-INF/src/org/hartmath/server/cache/CachedPage.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CachedPage.java 2 May 2004 12:43:06 -0000 1.2 --- CachedPage.java 2 May 2004 17:34:10 -0000 1.3 *************** *** 1,2 **** --- 1,19 ---- + /* + * This file is part of the "HMath MathML BLOG/Wiki Engine". + * + * Copyright (c) 2004 Klaus Hartlage All Rights Reserved. + * + * Please visit http://www.hmath.org/ for updates and contact. + * + * --LICENSE NOTICE-- This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser + * General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any + * later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free + * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --LICENSE NOTICE-- + */ package org.hartmath.server.cache; --- NEW FILE: LRUCache.java --- /* * This file is part of the "HMath MathML BLOG/Wiki Engine". * * Copyright (c) 2004 Klaus Hartlage All Rights Reserved. * * Please visit http://www.hmath.org/ for updates and contact. * * --LICENSE NOTICE-- This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser * General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any * later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --LICENSE NOTICE-- */ package org.hartmath.server.cache; import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; /** * Least recently used cache for CachedPages * * Ref.: JDCTechTips July 2002 */ public class LRUCache { private final int MAX_NUMBER_OF_PAGES = 1000; private Map cache; public LRUCache() { cache = new LinkedHashMap(MAX_NUMBER_OF_PAGES+1, .75F) { public boolean removeEldestEntry(Map.Entry eldest) { return size() > MAX_NUMBER_OF_PAGES; } }; // the cache must be thread-safe: cache = (Map)Collections.synchronizedMap(cache); } /** * @param key * @return */ public boolean containsKey(String key) { return cache.containsKey(key); } /** * @param value * @return */ public boolean containsValue(CachedPage value) { return cache.containsValue(value); } /** * @param key * @return */ public CachedPage get(String key) { return (CachedPage)cache.get(key); } /** * @param key * @param value * @return */ public CachedPage put(String key, CachedPage value) { return (CachedPage)cache.put(key, value); } /** * @param key * @return */ public Object remove(String key) { return cache.remove(key); } } Index: CachedPageGenerator.java =================================================================== RCS file: /cvsroot/hmath/org.hmath.server/WEB-INF/src/org/hartmath/server/cache/CachedPageGenerator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CachedPageGenerator.java 2 May 2004 12:43:06 -0000 1.1 --- CachedPageGenerator.java 2 May 2004 17:34:10 -0000 1.2 *************** *** 1,10 **** package org.hartmath.server.cache; import java.util.ArrayList; - import java.util.HashMap; public class CachedPageGenerator extends ClassLoader implements ICachedPageGenerator { public static long CLASS_COUNTER = 0; ! public static HashMap PAGE_MAP = new HashMap(); public final static int HTML = 1; public final static Integer HTML_TEXT = new Integer(HTML); --- 1,26 ---- + /* + * This file is part of the "HMath MathML BLOG/Wiki Engine". + * + * Copyright (c) 2004 Klaus Hartlage All Rights Reserved. + * + * Please visit http://www.hmath.org/ for updates and contact. + * + * --LICENSE NOTICE-- This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser + * General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any + * later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free + * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --LICENSE NOTICE-- + */ package org.hartmath.server.cache; import java.util.ArrayList; public class CachedPageGenerator extends ClassLoader implements ICachedPageGenerator { public static long CLASS_COUNTER = 0; ! public static LRUCache LRU_CACHED_PAGE_MAP = new LRUCache(); public final static int HTML = 1; public final static Integer HTML_TEXT = new Integer(HTML); |