Cache cache = Redis.use(); String key = "test_key"; String filed = "test_field"; long val = cache.hincrBy(key, filed, 1L); Map map = cache.hgetAll(key);
执行代码后,报错空指针,报错信息如下
Exception in thread "Timer-0" java.lang.RuntimeException: java.io.IOException: java.lang.NullPointerException
at com.jfinal.plugin.redis.serializer.FstSerializer.valueFromBytes(FstSerializer.java:78)
at com.jfinal.plugin.redis.Cache.valueFromBytes(Cache.java:1217)
at com.jfinal.plugin.redis.Cache.hgetAll(Cache.java:527)
可以写个工具方法先得到 jedis 对象,再从里头获取,记得要在 finally 中关闭 jedis 连接