Package railo.commons.io.cache

Examples of railo.commons.io.cache.Cache


    return call(pc, id, throwOnError, null);
  }
 
  public static String call(PageContext pc, String id, boolean throwOnError, String cacheName) throws PageException {
    try {
      Cache cache = Util.getCache(pc,cacheName,ConfigImpl.CACHE_DEFAULT_OBJECT);
      if(!cache.remove(Util.key(id)) && throwOnError){
        throw new ApplicationException("can not remove the element with the following id ["+id+"]");
     
    }
    catch (IOException e) {
      throw Caster.toPageException(e);
View Full Code Here


    // compatibility behavior, second parameter is a cacheName
    if(objThrowWhenNotExist instanceof String) {
      String cacheName=(String)objThrowWhenNotExist;
      if(!StringUtil.isEmpty(cacheName)) {
        try {
          Cache cache = Util.getCache(pc.getConfig(),cacheName,null);
         
          if(cache!=null)
            return _call(pc, key, false, cache);
        }
        catch (IOException e) {
View Full Code Here

   
    Boolean throwWhenNotExist=Caster.toBoolean(objThrowWhenNotExist,null);
    if(throwWhenNotExist==null)throw new FunctionException(pc, "cacheGet", 2, "ThrowWhenNotExist", "arguments needs to be a boolean value");
   
    try {
      Cache cache = Util.getCache(pc,cacheName,ConfigImpl.CACHE_DEFAULT_OBJECT);
      return _call(pc, key, throwWhenNotExist.booleanValue(), cache);
    } catch (IOException e) {
      throw Caster.toPageException(e);
    }
  }
View Full Code Here

 
  public static String call(PageContext pc, Object ids, boolean throwOnError, String cacheName) throws PageException {
    Array arr = toArray(ids);//
    Iterator it = arr.valueIterator();
    String id;
    Cache cache;
    try {
      cache = Util.getCache(pc,cacheName,ConfigImpl.CACHE_DEFAULT_OBJECT);
    } catch (IOException e) {
      throw Caster.toPageException(e);
    }
    StringBuffer sb=null;
    try{
      while(it.hasNext()){
        id= Util.key(Caster.toString(it.next()));
        if(!cache.remove(id) && throwOnError){
          if(sb==null)sb=new StringBuffer();
          else sb.append(',');
          sb.append(id);
        }   
      }
View Full Code Here

 
  private static String _call(PageContext pc, String key,Object value,Long timeSpan, Long idleTime,String cacheName) throws PageException {
    //if(timeSpan!=null && timeSpan.longValue()==0L) return "";
    //if(idleTime!=null && idleTime.longValue()==0L) return "";
    try {
      Cache cache = Util.getCache(pc,cacheName,ConfigImpl.CACHE_DEFAULT_OBJECT);
      cache.put(Util.key(key), value, idleTime, timeSpan);
    } catch (Exception e) {
      throw Caster.toPageException(e);
    }
   
    return "";
View Full Code Here

    return call(pc, id,null);
  }
 
  public static Struct call(PageContext pc, String id, String cacheName) throws PageException {
    try {
      Cache cache = Util.getCache(pc,cacheName,ConfigImpl.CACHE_DEFAULT_OBJECT);
      CacheEntry entry = cache.getCacheEntry(Util.key(id));
     
      Struct info=new StructImpl();
      info.set(CACHE_HITCOUNT, new Double(cache.hitCount()));
      info.set(CACHE_MISSCOUNT, new Double(cache.missCount()));
      info.set(CACHE_CUSTOM, cache.getCustomInfo());
      info.set(KeyConstants._custom, entry.getCustomInfo());
     
      info.set(CREATED_TIME, entry.created());
      info.set(KeyConstants._hitcount, new Double(entry.hitCount()));
      info.set(IDLE_TIME, new Double(entry.idleTimeSpan()));
View Full Code Here

    String name=null;
    if(pc!=null && pc.getApplicationContext()!=null)
      name=pc.getApplicationContext().getDefaultCacheName(type);
    Config config=ThreadLocalPageContext.getConfig(pc);
    if(!StringUtil.isEmpty(name)){
      Cache cc = getCache(config, name, null);
      if(cc!=null) return cc;
    }
   
    // get default from config
    CacheConnection cc= ((ConfigImpl)config).getCacheDefaultConnection(type);
    if(cc==null) return defaultValue;
    try {
      return cc.getInstance(config);
    } catch (Throwable t) {
      return defaultValue;
    }
  }
View Full Code Here

   */
  public static Cache getDefault(PageContext pc, int type) throws IOException {
    // get default from application conetx
    String name=pc!=null?pc.getApplicationContext().getDefaultCacheName(type):null;
    if(!StringUtil.isEmpty(name)){
      Cache cc = getCache(pc.getConfig(), name, null);
      if(cc!=null) return cc;
    }
   
    // get default from config
    Config config = ThreadLocalPageContext.getConfig(pc);
    CacheConnection cc= ((ConfigImpl)config).getCacheDefaultConnection(type);
    if(cc==null) throw new CacheException("there is no default "+toStringType(type,"")+" cache defined, you need to define this default cache in the Railo Administrator");
    return cc.getInstance(config);
   
   
  }
View Full Code Here

    } catch (Throwable e) {
      return false;
    }
  }
  public static void remove(ConfigWeb config, CacheConnection cc) throws Throwable  {
    Cache c = cc.getInstance(config);
    // FUTURE no reflection needed
   
   
    Method remove=null;
    try{
      remove = c.getClass().getMethod("remove", new Class[0]);
     
    }
    catch(Exception ioe){
      c.remove((CacheEntryFilter)null);
      return;
    }
   
    try {
      remove.invoke(c, new Object[0]);
View Full Code Here

    if(obj instanceof CacheResourceCore) return (CacheResourceCore) obj;
    return null;
  }

  void touch(String path,String name) {
    Cache cache = getCache();
    CacheEntry ce = cache.getCacheEntry(toKey(path,name),null);
    if(ce!=null){
      cache.put(ce.getKey(), ce.getValue(), ce.idleTimeSpan(), ce.liveTimeSpan());
    }
  }
View Full Code Here

TOP

Related Classes of railo.commons.io.cache.Cache

Copyright © 2018 www.massapicom. 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.