001    package railo.runtime.query;
002    
003    import java.io.IOException;
004    import java.util.Date;
005    
006    import railo.runtime.PageContext;
007    import railo.runtime.db.SQL;
008    import railo.runtime.type.Query;
009    
010    /**
011     * interface for a query cache
012     */
013    public interface QueryCache {
014    
015        /**
016         * clear expired queries from cache
017         * @throws IOException 
018         */
019        public abstract void clearUnused(PageContext pc) throws IOException;
020    
021        /**
022         * returns a Query from Query Cache or null if no match found
023         * @param sql
024         * @param datasource
025         * @param username
026         * @param password
027         * @param cacheAfter
028         * @return Query
029         */
030        public abstract Query getQuery(PageContext pc,SQL sql, String datasource, String username, String password, Date cacheAfter);
031        
032        
033        /**
034         * sets a Query to Cache
035         * @param sql
036         * @param datasource
037         * @param username
038         * @param password
039         * @param value
040         * @param cacheBefore
041         */
042        public abstract void set(PageContext pc,SQL sql, String datasource, String username,
043                String password, Object value, Date cacheBefore);
044    
045        /**
046         * clear the cache
047         * @throws IOException 
048         */
049        public abstract void clear(PageContext pc);
050    
051            /**
052             * clear the cache
053         * @param filter
054             */
055            public abstract void clear(PageContext pc, QueryCacheFilter filter);
056    
057            /**
058             * removes query from cache
059             * @param sql
060             * @param datasource
061             * @param username
062             * @param password
063             * @throws IOException 
064             */
065            public abstract void remove(PageContext pc,SQL sql, String datasource,String username, String password);
066    
067            public abstract Object get(PageContext pc,SQL sql, String datasource,String username, String password, Date cachedafter);
068    
069            public abstract int size(PageContext pc);
070    }