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;
}
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;
}
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;
}
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();
}
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()]);
}
Aggregations