001 package railo.runtime.functions.cache; 002 003 import java.io.IOException; 004 005 import railo.runtime.PageContext; 006 import railo.runtime.config.ConfigImpl; 007 import railo.runtime.exp.PageException; 008 import railo.runtime.ext.function.Function; 009 import railo.runtime.op.Caster; 010 011 /** 012 * 013 */ 014 public final class CacheCount implements Function { 015 016 private static final long serialVersionUID = 4192649311671009474L; 017 018 public static double call(PageContext pc) throws PageException { 019 return call(pc,null); 020 021 } 022 023 public static double call(PageContext pc, String cacheName) throws PageException { 024 try { 025 return Util.getCache(pc,cacheName,ConfigImpl.CACHE_DEFAULT_OBJECT).keys().size(); 026 } catch (IOException e) { 027 throw Caster.toPageException(e); 028 } 029 } 030 }