Package com.opensymphony.oscache.base

Source Code of com.opensymphony.oscache.base.OSCacheUtility

package com.opensymphony.oscache.base;

import javax.servlet.ServletContext;

import org.apache.log4j.Logger;
import org.infoglue.cms.util.CmsPropertyHandler;

import com.opensymphony.oscache.web.ServletCacheAdministrator;

public final class OSCacheUtility
{
    public final static Logger logger = Logger.getLogger(OSCacheUtility.class.getName());

  public static void setServletCacheParams(ServletContext context)
  {
    ServletCacheAdministrator servletCacheAdministrator = ServletCacheAdministrator.getInstance(context);
    servletCacheAdministrator.flushAll();
    Cache cache = servletCacheAdministrator.getAppScopeCache(context);
   
    servletCacheAdministrator.setAlgorithmClass("com.opensymphony.oscache.base.algorithm.ImprovedLRUCache");
   
    int capacity = 5000;

    String cacheCapacity = (String)CmsPropertyHandler.getCacheSettings().get("CACHE_CAPACITY_oscache_ServletCache");
    if(logger.isInfoEnabled())
      logger.info("cacheCapacity from application settings: " + cacheCapacity);
   
    if(cacheCapacity != null && !cacheCapacity.equals(""))
      {
      try
      {
        capacity = Integer.parseInt(cacheCapacity);
      }
      catch(Exception e)
      {
        e.printStackTrace();
      }
    }
   
    if(logger.isInfoEnabled())
      logger.info("Setting OSCache servlet cache to " + capacity);
   
    cache.setCapacity(capacity);       
  }
 
  public static void clear(Cache cache)
  {
    cache.clear();
  }
 
 
  /*
  public static synchronized String getStatistics(Cache cache)
  {
    cache
  }
  */
TOP

Related Classes of com.opensymphony.oscache.base.OSCacheUtility

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.