use of com.alicp.jetcache.CacheConfigException in project jetcache by alibaba.
the class ExpressionUtil method parseEL.
public static Object[] parseEL(String script) {
if (script == null || script.trim().equals("")) {
return null;
}
Object[] rt = new Object[2];
Matcher matcher = pattern.matcher(script);
if (!matcher.matches()) {
return null;
}
String s = matcher.group(1);
if ("spel".equals(s)) {
rt[0] = EL.SPRING_EL;
} else if ("mvel".equals(s)) {
rt[0] = EL.MVEL;
} else if ("buildin".equals(s)) {
rt[0] = EL.BUILD_IN;
} else {
throw new CacheConfigException("Can't parse \"" + script + "\"");
}
rt[1] = matcher.group(2);
return rt;
}
use of com.alicp.jetcache.CacheConfigException in project jetcache by alibaba.
the class CacheContext method buildLocal.
protected Cache buildLocal(CacheAnnoConfig cacheAnnoConfig, String area) {
Cache cache;
EmbeddedCacheBuilder cacheBuilder = (EmbeddedCacheBuilder) globalCacheConfig.getLocalCacheBuilders().get(area);
if (cacheBuilder == null) {
throw new CacheConfigException("no local cache builder: " + area);
}
cacheBuilder = (EmbeddedCacheBuilder) cacheBuilder.clone();
if (cacheAnnoConfig.getLocalLimit() != CacheConsts.UNDEFINED_INT) {
cacheBuilder.setLimit(cacheAnnoConfig.getLocalLimit());
}
if (cacheAnnoConfig.getExpire() > 0) {
cacheBuilder.expireAfterWrite(cacheAnnoConfig.getExpire(), cacheAnnoConfig.getTimeUnit());
}
if (!CacheConsts.UNDEFINED_STRING.equals(cacheAnnoConfig.getKeyConvertor())) {
cacheBuilder.setKeyConvertor(configProvider.parseKeyConvertor(cacheAnnoConfig.getKeyConvertor()));
}
cache = cacheBuilder.buildCache();
return cache;
}
use of com.alicp.jetcache.CacheConfigException in project jetcache by alibaba.
the class LutteceConnectionManager method asyncCommands.
public Object asyncCommands(AbstractRedisClient redisClient) {
connection(redisClient);
LutteceObjects lo = getLutteceObjectsFromMap(redisClient);
if (lo.asyncCommands == null) {
if (lo.connection instanceof StatefulRedisConnection) {
lo.asyncCommands = ((StatefulRedisConnection) lo.connection).async();
} else if (lo.connection instanceof StatefulRedisClusterConnection) {
lo.asyncCommands = ((StatefulRedisClusterConnection) lo.connection).async();
} else {
throw new CacheConfigException("type " + lo.connection.getClass() + " is not supported");
}
}
return lo.asyncCommands;
}
use of com.alicp.jetcache.CacheConfigException in project jetcache by alibaba.
the class CacheContext method buildRemote.
protected Cache buildRemote(CacheAnnoConfig cacheAnnoConfig, String area, String cacheName) {
ExternalCacheBuilder cacheBuilder = (ExternalCacheBuilder) globalCacheConfig.getRemoteCacheBuilders().get(area);
if (cacheBuilder == null) {
throw new CacheConfigException("no remote cache builder: " + area);
}
cacheBuilder = (ExternalCacheBuilder) cacheBuilder.clone();
if (cacheAnnoConfig.getExpire() > 0) {
cacheBuilder.expireAfterWrite(cacheAnnoConfig.getExpire(), cacheAnnoConfig.getTimeUnit());
}
if (cacheBuilder.getConfig().getKeyPrefix() != null) {
cacheBuilder.setKeyPrefix(cacheBuilder.getConfig().getKeyPrefix() + cacheName);
} else {
cacheBuilder.setKeyPrefix(cacheName);
}
if (!CacheConsts.UNDEFINED_STRING.equals(cacheAnnoConfig.getKeyConvertor())) {
cacheBuilder.setKeyConvertor(configProvider.parseKeyConvertor(cacheAnnoConfig.getKeyConvertor()));
}
if (!CacheConsts.UNDEFINED_STRING.equals(cacheAnnoConfig.getSerialPolicy())) {
cacheBuilder.setValueEncoder(configProvider.parseValueEncoder(cacheAnnoConfig.getSerialPolicy()));
cacheBuilder.setValueDecoder(configProvider.parseValueDecoder(cacheAnnoConfig.getSerialPolicy()));
}
return cacheBuilder.buildCache();
}
use of com.alicp.jetcache.CacheConfigException in project jetcache by alibaba.
the class LutteceConnectionManager method commands.
public Object commands(AbstractRedisClient redisClient) {
connection(redisClient);
LutteceObjects lo = getLutteceObjectsFromMap(redisClient);
if (lo.commands == null) {
if (lo.connection instanceof StatefulRedisConnection) {
lo.commands = ((StatefulRedisConnection) lo.connection).sync();
} else if (lo.connection instanceof StatefulRedisClusterConnection) {
lo.commands = ((StatefulRedisClusterConnection) lo.connection).sync();
} else {
throw new CacheConfigException("type " + lo.connection.getClass() + " is not supported");
}
}
return lo.commands;
}
Aggregations