spring-data-redis相关api
生活随笔
收集整理的這篇文章主要介紹了
spring-data-redis相关api
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
2019獨角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>
package com.dzq.demo.sys.auth.rest;import com.dzq.demo.common.webcomponent.Response; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController;import javax.servlet.http.HttpServletRequest;@RestController @RequestMapping("redis-test") public class RedisTest {@Autowiredprivate RedisTemplate<String, String> redisTemplate;@Autowiredprivate StringRedisTemplate stringRedisTemplate;@RequestMapping(method = RequestMethod.GET)public Response test(HttpServletRequest request) {//設(shè)置指定鍵的值 、 獲取指定鍵的值redisTemplate.opsForValue().set("key", "value");redisTemplate.opsForValue().get("key");/*** 其他類型的操作方法redisTemplate.opsForHash()redisTemplate.opsForList()redisTemplate.opsForSet()redisTemplate.opsForZSet()*///設(shè)置指定鍵的值 、 獲取指定鍵的值redisTemplate.boundValueOps("key").set("value");redisTemplate.boundValueOps("key").get();/***其他類型的操作方法redisTemplate.boundHashOps("key")redisTemplate.boundListOps("key")redisTemplate.boundSetOps("key")redisTemplate.boundZSetOps("key")*/return Response.success();} }?
?
轉(zhuǎn)載于:https://my.oschina.net/u/1185936/blog/1518873
總結(jié)
以上是生活随笔為你收集整理的spring-data-redis相关api的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 魔兽世界怀旧服猎人鳄鱼撕咬技能怎么学 怀
- 下一篇: 炉石传说酒馆战棋帕奇维克玩法技巧解析 酒