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.
 
 
 
 
 
 

42 lines
1.0 KiB

package com.fr.plugin.db.redis.help.client;
import com.fanruan.api.log.LogKit;
import com.fr.plugin.db.redis.help.ScriptBridge;
import com.fr.plugin.db.redis.help.RedisClient;
import 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 {
LogKit.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 {
LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
}
}
}