我想在linux上编写一个C程序,它不断刷新屏幕并实时更新(例如,类似于top终端中的命令).任何人都可以指出我正确的方向.
我有一个代码,我已经实现了缓存机制.以前它是基于番石榴的缓存,现在我正在转向Redis考虑集中缓存的需求.
但是我担心它的性能,因为与guave相比,我看到redis的性能极低.
我已经测量了api的性能,它从缓存获取一个类对象.在Guava的情况下它是5ms,而在Redis中它获得200ms.
这是负载测试情况下的平均响应,如果单个请求响应没有太大差异.
我已经使用缓存抽象实现了Spring数据Redis.
以下是Redis配置示例:
@Bean
public RedisConnectionFactory redisConnectionFactory(@Value("${redis.host}") String redisHost,
@Value("${redis.port}") Integer redisPort) {
JedisConnectionFactory cf = new JedisConnectionFactory();
cf.setHostName(redisHost);
cf.setPort(redisPort);
cf.setUsePool(true);
JedisPoolConfig jedisPool = new JedisPoolConfig();
jedisPool.setMaxTotal(500);
cf.setPoolConfig(jedisPool);
return cf;
}
@Bean(name = "redisTemplate")
RedisTemplate<Object,Object> redisTemplate() {
final RedisTemplate<Object,Object> template = new RedisTemplate<Object,Object>();
template.setConnectionFactory(applicationContext.getBean(RedisConnectionFactory.class));
return template;
}
@Bean
public CacheManager cacheManager() {
if(isRedisEnabled)
{
RedisTemplate<?,?> template = (RedisTemplate<?, ?>) applicationContext.getBean("redisTemplate");
RedisCacheManager redisCacheManager = new PieRedisCacheManager(template);
redisCacheManager.setUsePrefix(true);
try
{
template.getConnectionFactory().getConnection();
}
catch(Exception e)
{
LOG.error("Unable to connect to …Run Code Online (Sandbox Code Playgroud)我有一个具有某些数值的变量x = 5;。
我想纠正这样的表达式:
if arr = [4,7,10]包含x在mvel中。
这可能吗,如果可以,怎么做?
截至目前,我必须正确表达为:
x == 4 || x == 7 || x == 10
Run Code Online (Sandbox Code Playgroud)
但因为我可能有一个很大的清单,可以将其做成类似的东西吗
x in [4,7,10,...]
Run Code Online (Sandbox Code Playgroud)
代码 :
for(Rule rule: ruleList)
{
String expresssion = rule.getConditionExpression();
boolean result = (Boolean) expressionHandler.execute(expresssion,ruleEvalData);
}
Run Code Online (Sandbox Code Playgroud)
这里的表达式如下:
表达式 = 'x == 4 || x == 7 || x == 10';
并且ruleEvalData 将包含x。
我想知道是否
表达式 ='x in [4,7,10,...]' 在MVEL 中可能吗?