Package railo.commons.io.cache

Examples of railo.commons.io.cache.CacheEntry


  private void _clear(PageContext pc,QueryCacheFilter filter) throws IOException {
    Cache c = getCache(pc);
    Iterator it = c.entries().iterator();
      String key;
      CacheEntry entry;
      QueryCacheEntry ce;
      Query q;
      while(it.hasNext()){
      entry=(CacheEntry) it.next();
      if(!(entry.getValue() instanceof QueryCacheEntry)) continue;
      ce=(QueryCacheEntry) entry.getValue();
      if(!(ce.getValue() instanceof Query)) continue;
      q=(Query) ce.getValue();
      key=entry.getKey();
        if(filter.accept(q.getSql().toString())){
        c.remove(key);
        }
      }
  }
View Full Code Here


  private void clean(CacheConnection cc, ConfigWebImpl config) throws IOException {
    Cache cache = cc.getInstance(config);
    int len=filter.length(),index;
    List<CacheEntry> entries = cache.entries(filter);
    CacheEntry ce;
    long expires;
   
    String key,appname,cfid;
    if(entries.size()>0){
      Iterator<CacheEntry> it = entries.iterator();
      while(it.hasNext()){
        ce=it.next();
        expires=ce.lastModified().getTime()+ce.idleTimeSpan()-StorageScopeCache.SAVE_EXPIRES_OFFSET;
        if(expires<=System.currentTimeMillis()) {
          key=ce.getKey().substring(len);
          index=key.indexOf(':');
          cfid=key.substring(0,index);
          appname=key.substring(index+1);
         
          if(listener!=null)listener.doEnd(engine, this,appname, cfid);
          info("remove "+strType+"/"+appname+"/"+cfid+" from cache "+cc.getName());
          engine.remove(type,appname,cfid);
          cache.remove(ce.getKey());
        }
      }
    }
   
    //engine.remove(type,appName,cfid);
View Full Code Here

      pageContext.setVariable(name,CacheGet.call(pageContext, id,throwOnError,cachename))
    }
    else {
      railo.commons.io.cache.Cache cache =
        Util.getCache(pageContext,cachename,ConfigImpl.CACHE_DEFAULT_OBJECT);
      CacheEntry entry = throwOnError?cache.getCacheEntry(Util.key(id)):cache.getCacheEntry(Util.key(id),null);
      if(entry!=null){
        pageContext.setVariable(name,entry.getValue());
        pageContext.setVariable(metadata,entry.getCustomInfo());
      }
      else {
        pageContext.setVariable(metadata,new StructImpl());
      }
    }
View Full Code Here

    try {
      Cache cache = Util.getCache(pc,cacheName,ConfigImpl.CACHE_DEFAULT_OBJECT);
      List<CacheEntry> entries = CacheGetAllIds.isFilter(filter)?cache.entries(new WildCardFilter(filter,true)):cache.entries();
      Iterator<CacheEntry> it=entries.iterator();
      Struct sct = new StructImpl();
      CacheEntry entry;
      while(it.hasNext()){
        entry= it.next();
        sct.setEL(KeyImpl.getInstance(entry.getKey()),entry.getValue());
      }
      return sct;
    } catch (Exception e) {
      throw Caster.toPageException(e);
    }
View Full Code Here

  }
 
  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()));
      info.set(LAST_HIT, entry.lastHit());
      info.set(LAST_UPDATED, entry.lastModified());
      info.set(KeyConstants._size, new Double(entry.size()));
      info.set(KeyConstants._timespan, new Double(entry.liveTimeSpan()));
      return info;
    } catch (IOException e) {
      throw Caster.toPageException(e);
    }
  }
View Full Code Here

  public List<CacheEntry> keys(CacheEntryFilter filter) throws IOException {
    List<String> keys = keys();
    List<CacheEntry> list=new ArrayList<CacheEntry>();
    Iterator<String> it = keys.iterator();
    String key;
    CacheEntry entry;
    while(it.hasNext()){
      key=it.next();
      entry=getQuiet(key,null);
      if(filter.accept(entry))list.add(entry);
    }
View Full Code Here

  @Override
  public List<CacheEntry> entries(CacheEntryFilter filter) throws IOException {
    List<String> keys = keys();
    List<CacheEntry> list=new ArrayList<CacheEntry>();
    Iterator<String> it = keys.iterator();
    CacheEntry entry;
    while(it.hasNext()){
      entry=getQuiet(it.next(),null);
      if(filter.accept(entry))list.add(entry);
    }
    return list;
View Full Code Here

  public List values(CacheEntryFilter filter) throws IOException {
    List<String> keys = keys();
    List<Object> list=new ArrayList<Object>();
    Iterator<String> it = keys.iterator();
    String key;
    CacheEntry entry;
    while(it.hasNext()){
      key=it.next();
      entry=getQuiet(key,null);
      if(filter.accept(entry))list.add(entry.getValue());
    }
    return list;
  }
View Full Code Here

  public int remove(CacheEntryFilter filter) throws IOException {
    List<String> keys = keys();
    int count=0;
    Iterator<String> it = keys.iterator();
    String key;
    CacheEntry entry;
    while(it.hasNext()){
      key=it.next();
      entry=getQuiet(key,null);
      if(filter==null || filter.accept(entry)){
        remove(key);
View Full Code Here

    return getCacheEntry(key).getValue();
  }

  @Override
  public Object getValue(String key, Object defaultValue) {
    CacheEntry entry = getCacheEntry(key,null);
    if(entry==null) return defaultValue;
    return entry.getValue();
  }
View Full Code Here

TOP

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

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.