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 CacheKeyExists implements Function {
015            
016            private static final long serialVersionUID = -5656876871645994195L;
017    
018            public static boolean call(PageContext pc, String key) throws PageException {
019                    return call(pc, key, null);
020            }
021            
022            public static boolean call(PageContext pc, String key,String cacheName) throws PageException {
023                    try {
024                            return Util.getCache(pc.getConfig(),cacheName,ConfigImpl.CACHE_DEFAULT_OBJECT).contains(Util.key(key));
025                    } catch (IOException e) {
026                            throw Caster.toPageException(e);
027                    }
028            }
029            
030    }