Search in sources :

Example 16 with CacheConnection

use of lucee.runtime.cache.CacheConnection in project Lucee by lucee.

the class PageContextImpl method getCacheConnection.

public CacheConnection getCacheConnection(String cacheName) throws CacheException {
    cacheName = cacheName.toLowerCase().trim();
    CacheConnection cc = null;
    if (getApplicationContext() != null)
        cc = ((ApplicationContextSupport) getApplicationContext()).getCacheConnection(cacheName, null);
    if (cc == null)
        cc = config.getCacheConnections().get(cacheName);
    if (cc == null)
        throw CacheUtil.noCache(config, cacheName);
    return cc;
}
Also used : ApplicationContextSupport(lucee.runtime.listener.ApplicationContextSupport) CacheConnection(lucee.runtime.cache.CacheConnection)

Example 17 with CacheConnection

use of lucee.runtime.cache.CacheConnection in project Lucee by lucee.

the class XMLConfigWebFactory method _toArguments.

private static Struct[] _toArguments(List<CacheConnection> list) {
    Iterator<CacheConnection> it = list.iterator();
    Struct[] args = new Struct[list.size()];
    int index = 0;
    while (it.hasNext()) {
        args[index++] = it.next().getCustom();
    }
    return args;
}
Also used : ServerCacheConnection(lucee.runtime.cache.ServerCacheConnection) CacheConnection(lucee.runtime.cache.CacheConnection) lucee.aprint(lucee.aprint) Struct(lucee.runtime.type.Struct)

Example 18 with CacheConnection

use of lucee.runtime.cache.CacheConnection in project Lucee by lucee.

the class XMLConfigWebFactory method _toCacheNames.

private static String[] _toCacheNames(List<CacheConnection> list) {
    Iterator<CacheConnection> it = list.iterator();
    String[] names = new String[list.size()];
    int index = 0;
    while (it.hasNext()) {
        names[index++] = it.next().getName();
    }
    return names;
}
Also used : ServerCacheConnection(lucee.runtime.cache.ServerCacheConnection) CacheConnection(lucee.runtime.cache.CacheConnection) lucee.aprint(lucee.aprint)

Example 19 with CacheConnection

use of lucee.runtime.cache.CacheConnection in project Lucee by lucee.

the class CacheGetDefaultCacheName method call.

public static String call(PageContext pc, String strType) throws PageException {
    int type = CacheUtil.toType(strType, Config.CACHE_TYPE_NONE);
    if (type == Config.CACHE_TYPE_NONE)
        throw new FunctionException(pc, "CacheGetDefaultCacheName", 1, "type", "invalid type defintion [" + strType + "], valid types are [object,resource,template,query]");
    ConfigImpl config = (ConfigImpl) pc.getConfig();
    CacheConnection conn = config.getCacheDefaultConnection(type);
    if (conn == null)
        throw new ExpressionException("there is no default cache defined for type [" + strType + "]");
    return conn.getName();
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) CacheConnection(lucee.runtime.cache.CacheConnection) ConfigImpl(lucee.runtime.config.ConfigImpl) ExpressionException(lucee.runtime.exp.ExpressionException)

Example 20 with CacheConnection

use of lucee.runtime.cache.CacheConnection in project Lucee by lucee.

the class CacheSetProperties method getCaches.

private static CacheConnection[] getCaches(PageContext pc, String cacheName) throws CacheException {
    ConfigImpl config = (ConfigImpl) pc.getConfig();
    if (StringUtil.isEmpty(cacheName)) {
        return new CacheConnection[] { config.getCacheDefaultConnection(Config.CACHE_TYPE_OBJECT), config.getCacheDefaultConnection(Config.CACHE_TYPE_TEMPLATE) };
    // MUST which one is first
    }
    ArrayList<CacheConnection> list = new ArrayList<CacheConnection>();
    String name;
    String[] names = ListUtil.listToStringArray(cacheName, ',');
    for (int i = 0; i < names.length; i++) {
        name = names[i].trim().toLowerCase();
        if (name.equalsIgnoreCase("template"))
            list.add(config.getCacheDefaultConnection(Config.CACHE_TYPE_TEMPLATE));
        else if (name.equalsIgnoreCase("object"))
            list.add(config.getCacheDefaultConnection(Config.CACHE_TYPE_OBJECT));
        else {
            CacheConnection cc = config.getCacheConnections().get(name);
            if (cc == null)
                throw new CacheException("there is no cache defined with name [" + name + "]");
            list.add(cc);
        }
    }
    return list.toArray(new CacheConnection[list.size()]);
}
Also used : CacheException(lucee.commons.io.cache.exp.CacheException) ArrayList(java.util.ArrayList) CacheConnection(lucee.runtime.cache.CacheConnection) ConfigImpl(lucee.runtime.config.ConfigImpl)

Aggregations

CacheConnection (lucee.runtime.cache.CacheConnection)21 Struct (lucee.runtime.type.Struct)9 ApplicationException (lucee.runtime.exp.ApplicationException)7 Entry (java.util.Map.Entry)6 Map (java.util.Map)5 DataSource (lucee.runtime.db.DataSource)4 PageException (lucee.runtime.exp.PageException)4 ApplicationContextSupport (lucee.runtime.listener.ApplicationContextSupport)4 StructImpl (lucee.runtime.type.StructImpl)4 HashMap (java.util.HashMap)3 Iterator (java.util.Iterator)3 lucee.aprint (lucee.aprint)3 ServerCacheConnection (lucee.runtime.cache.ServerCacheConnection)3 ClassDefinition (lucee.runtime.db.ClassDefinition)3 ExpressionException (lucee.runtime.exp.ExpressionException)3 ApplicationContext (lucee.runtime.listener.ApplicationContext)3 IOException (java.io.IOException)2 Method (java.lang.reflect.Method)2 ArrayList (java.util.ArrayList)2 CacheConnectionImpl (lucee.runtime.cache.CacheConnectionImpl)2