Blame | Last modification | View Log | RSS feed
package in.shop2020.serving.cache;import in.shop2020.serving.utils.FileUtils;import in.shop2020.serving.utils.Utils;import java.io.File;import java.io.IOException;import net.sf.ehcache.CacheManager;import org.apache.log4j.Logger;public class CategorySnippetCacheWrapper{private static Logger log = Logger.getLogger(CategorySnippetCacheWrapper.class);private static EhcacheWrapper<String, String> categorySnippetCache = new EhcacheWrapper<String, String>(EhcacheWrapper.CATEGORY_SNIPPET_CACHE_NAME, CacheManager.create());;public static String getSnippet(String docId){String snippet = categorySnippetCache.get(docId);if (snippet == null) {log.info("Loading category snippet from disk : " + docId);try {snippet = FileUtils.read(Utils.EXPORT_ENTITIES_PATH+ docId + File.separator + "CategorySnippet.html");if (snippet != null) {categorySnippetCache.put(docId, snippet);}} catch (IOException e) {log.error(e);}}else {log.info("Loading category snippet from cache : " + docId);}return snippet;}}