1 package org.roller.presentation.website; 2 3 import org.roller.util.LRUCache2; 4 5 11 public class ThemeCache 12 { 13 private static ThemeCache INSTANCE = new ThemeCache(); 14 private static String cacheName = "ThemeFiles"; 15 19 private static int maxObjects = 500; 20 21 private static LRUCache2 cache = new LRUCache2(maxObjects, 30 * 60 * 1000); 22 23 27 private long expireInterval = 1000l*60*60*24; 29 33 private static boolean cacheTemplateFiles = false; 34 35 36 private ThemeCache() { } 37 38 41 public static ThemeCache getInstance() 42 { 43 return INSTANCE; 44 } 45 46 49 public String putIntoCache(String themeName, String fileName, String template) 50 { 51 if (cacheTemplateFiles) 52 { 53 cache.put(themeName+":"+fileName, template); 54 } 55 return template; 56 57 } 58 59 63 public String getFromCache(String themeName, String fileName) 64 { 65 if (!cacheTemplateFiles) return null; 66 return (String ) cache.get(themeName + ":" + fileName); 67 } 68 69 72 public void removeFromCache(String themeName, String fileName) 73 { 74 if (!cacheTemplateFiles) return; 75 cache.purge( new String [] { themeName+":"+fileName } ); 76 } 77 78 79 87 public String [] setFileList(String themeDir, String [] fileNames) 88 { 89 if (cacheTemplateFiles) 90 { 91 cache.put(themeDir, fileNames); 92 } 93 return fileNames; 94 95 } 96 97 104 public String [] getFileList(String themeDir) 105 { 106 if (!cacheTemplateFiles) return null; 107 return (String [])cache.get(themeDir); 108 } 109 } 110 | Popular Tags |