|
|
|
@ -29,6 +29,7 @@ import com.jfinal.plugin.druid.DruidStatViewHandler;
|
|
|
|
|
import com.jfinal.plugin.druid.IDruidStatViewAuth;
|
|
|
|
|
import com.jfinal.plugin.redis.RedisPlugin;
|
|
|
|
|
import com.jfinal.plugin.redis.serializer.ISerializer;
|
|
|
|
|
import com.jfinal.plugin.redis.serializer.JdkSerializer;
|
|
|
|
|
import com.jfinal.server.undertow.UndertowServer;
|
|
|
|
|
import com.jfinal.template.Engine;
|
|
|
|
|
import redis.clients.jedis.util.SafeEncoder;
|
|
|
|
@ -151,34 +152,8 @@ public class Start extends JFinalConfig {
|
|
|
|
|
me.add(arp);
|
|
|
|
|
// 用于缓存模块的redis服务
|
|
|
|
|
RedisPlugin redis = new RedisPlugin("myRedis", PropKit.get("redis_ip"), PropKit.getInt("redis_port"), 10 * 1000);
|
|
|
|
|
redis.setSerializer(new ISerializer() {
|
|
|
|
|
@Override
|
|
|
|
|
public byte[] keyToBytes(String key) {
|
|
|
|
|
return SafeEncoder.encode(key);
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public String keyFromBytes(byte[] bytes) {
|
|
|
|
|
return SafeEncoder.encode(bytes);
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public byte[] fieldToBytes(Object field) {
|
|
|
|
|
return valueToBytes(field);
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public Object fieldFromBytes(byte[] bytes) {
|
|
|
|
|
return valueFromBytes(bytes);
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public byte[] valueToBytes(Object value) {
|
|
|
|
|
return SafeEncoder.encode(value.toString());
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public Object valueFromBytes(byte[] bytes) {
|
|
|
|
|
if(bytes == null || bytes.length == 0)
|
|
|
|
|
return null;
|
|
|
|
|
return SafeEncoder.encode(bytes);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
//JdkSerializer序列化的,比较简单依赖少:
|
|
|
|
|
redis.setSerializer(JdkSerializer.me);
|
|
|
|
|
|
|
|
|
|
//启动redis组件
|
|
|
|
|
me.add(redis);
|
|
|
|
|