Package jetbrick.template.utils

Examples of jetbrick.template.utils.TimedSizeCache


     *
     * @since 1.2.0
     */
    public static void application_cache(JetTagContext ctx, String name, long timeout) throws IOException {
        ServletContext sc = (ServletContext) ctx.getContext().get(JetWebContext.SERVLET_CONTEXT);
        TimedSizeCache cache = (TimedSizeCache) sc.getAttribute(TimedSizeCache.CACHE_KEY);
        if (cache == null) {
            cache = new TimedSizeCache(128);
            sc.setAttribute(TimedSizeCache.CACHE_KEY, cache);
        }
        Object value = cache.get(name);
        if (value == null) {
            value = ctx.getBodyContent();
            cache.put(name, value, timeout * 1000);
        }
        ctx.getWriter().print(value);
    }
View Full Code Here


     *
     * @since 1.2.0
     */
    public static void session_cache(JetTagContext ctx, String name, long timeout) throws IOException {
        HttpSession session = (HttpSession) ctx.getContext().get(JetWebContext.SESSION);
        TimedSizeCache cache = (TimedSizeCache) session.getAttribute(TimedSizeCache.CACHE_KEY);
        if (cache == null) {
            cache = new TimedSizeCache(128);
            session.setAttribute(TimedSizeCache.CACHE_KEY, cache);
        }
        Object value = cache.get(name);
        if (value == null) {
            value = ctx.getBodyContent();
            cache.put(name, value, timeout * 1000);
        }
        ctx.getWriter().print(value);
    }
View Full Code Here

TOP

Related Classes of jetbrick.template.utils.TimedSizeCache

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.