redis数据集插件。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

41 lines
1.1 KiB

package com.fr.plugin.db.redis.help.client;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.db.redis.help.ScriptBridge;
import com.fr.plugin.db.redis.help.RedisClient;
import com.fr.third.redis.clients.jedis.Jedis;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-08-26
*/
public abstract class BaseRedisClient<A, O> implements RedisClient<A, O> {
Jedis jedis;
BaseRedisClient(Jedis jedis) {
this.jedis = jedis;
}
@ScriptBridge
public String get(String key) {
long start = System.currentTimeMillis();
try {
return jedis.get(key);
} finally {
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
}
}
@ScriptBridge
public String hget(String key, String field) {
long start = System.currentTimeMillis();
try {
return jedis.hget(key, field);
} finally {
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
}
}
}