作家
登录

Spring Boot 整合 Redis 实现缓存操作

作者: 来源: 2017-04-17 14:05:50 阅读 我要评论

  •     @Override 
  •     public String toString() { 
  •         return "City{" + 
  •                 "id=" + id + 
  •                 ", provinceId=" + provinceId + 
  •                 ", cityName='" + cityName + '\'' + 
  •                 ", description='" + description + '\'' + 
  •                 '}'
  •     } 
  • 如不雅须要自定义序列化实现,只要实现 RedisSerializer 接口去实现即可,然后在应用 RedisTemplate.setValueSerializer 办法去设置你实现的序列化实现。

    1. package org.spring.springboot.service.impl; 
    2.   
    3. import org.slf4j.Logger; 
    4. import org.slf4j.LoggerFactory; 
    5. import org.spring.springboot.dao.CityDao; 
    6. import org.spring.springboot.domain.City; 
    7. import org.spring.springboot.service.CityService; 
    8. import org.springframework.beans.factory.annotation.Autowired; 
    9. import org.springframework.data.redis.core.RedisTemplate; 
    10. import org.springframework.data.redis.core.StringRedisTemplate; 
    11. import org.springframework.data.redis.core.ValueOperations; 
    12. import org.springframework.stereotype.Service; 
    13.   
    14. import java.util.List; 
    15. import java.util.concurrent.TimeUnit; 
    16.   
    17. /** 
    18.  * 城市营业逻辑实现类 
    19.  * <p> 
    20.  * Created by bysocket on 07/02/2017. 
    21.  */ 
    22. @Service 
    23. public class CityServiceImpl implements CityService { 
    24.   
    25.     private static final Logger LOGGER = LoggerFactory.getLogger(CityServiceImpl.class); 
    26.   
    27.     @Autowired 
    28.     private CityDao cityDao; 
    29.   
    30.     @Autowired 
    31.     private RedisTemplate redisTemplate; 
    32.   
    33.     /** 
    34.      * 获取城市逻辑: 
    35.      * 如不雅缓存存在,大年夜缓存中获取城市信息 
    36.      * 如不雅缓存不存在,大年夜 DB 中获取城市信息,然后插入缓存 
    37.      */ 
    38.     public

        推荐阅读

        Facebook的交互式神经网络可视化系统ActiVis,打开神经网络的“黑盒子”

      之前很多媒体在热烈评论辩论神经收集的“黑盒子”(black box)问题。复杂的模型处理猜测性工作负载时表示优胜,然则说到回溯体系是若何得出最终结不雅的,根本没有一种清楚的办>>>详细阅读


      本文标题:Spring Boot 整合 Redis 实现缓存操作

      地址:http://www.17bianji.com/lsqh/34801.html

    关键词: 探索发现

    乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

    网友点评
    自媒体专栏

    评论

    热度

    精彩导读
    栏目ID=71的表不存在(操作类型=0)