Fetch the repository succeeded.
This action will force synchronization from ztp/redisson-spring-boot-starter, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
@Controller
public class ObjectController {
@Resource
private RedissonObject redissonObject;
/**
* 设置值
* @param user
* @param request
* @param response
* @return
* @throws InterruptedException
*/
@RequestMapping("/object1")
@ResponseBody
public String object1(User user, HttpServletRequest request, HttpServletResponse response) throws InterruptedException {
User user1 = new User();
user1.setName("test");
user1.setAge("123");
redissonObject.setValue("object1", user1,-1L);
return "";
}
/**
* 获取值
* @param user
* @param request
* @param response
* @return
* @throws InterruptedException
*/
@RequestMapping("/object2")
@ResponseBody
public Object object2(User user, HttpServletRequest request, HttpServletResponse response) throws InterruptedException {
return redissonObject.getValue("object1");
}
/**
* 如果对象不存在则设置,否则不设置
* @param user
* @param request
* @param response
* @return
* @throws InterruptedException
*/
@RequestMapping("/object3")
@ResponseBody
public String object3(User user, HttpServletRequest request, HttpServletResponse response) throws InterruptedException {
return redissonObject.trySetValue("object1","object1-2")+"";
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。