当前位置: 首页 > news >正文

【SpringBoot】SpringBoot项目中实现数据缓存

步骤01 引入Redis依赖包

<dependency>

<groupId>org.springframework.boot

</groupId>

<artifactId>spring-boot-starter-data-redis

</artifactId>

</dependency>

步骤02 修改配置文件

在application.properties配置文件增加有关Redis的配置:

步骤03 验证测试

@SpringBootTest

public class TestRedisTemplate{

   @Autowired

    private RedisTemplate redisTemplate;

   @Test

   public void testString(){

    //调用set()方法创建缓存

    redisTemplate.opsForVaule().set("hello:redis","hello   spring  boot");

System.out.println("hello,redis:"+redisTemplate.opsForValue().get("hello:redis"));

}

}

 


http://www.mrgr.cn/news/438.html

相关文章:

  • 家里养有宠物,宠物空气净化器真的能除毛除臭吗?
  • 使用PowerShell自动化Windows系统管理任务
  • Squish 8.0现已发布
  • 用“文心一言”写的文章,看看AI写得怎么样?
  • PHP中英文企业官网系统应用插件
  • pyexiv2库 EXIF信息读取、写入
  • FFmpeg源码:av_log2函数分析
  • Redis缓存——缓存更新策略和常见的缓存问题
  • JVM的组成
  • 用Python实现9大回归算法详解——01. 线形回归算法
  • 《书生大模型实战营第3期》进阶岛 第4关: InternVL 多模态模型部署微调实践
  • 解析网络流量管理方案:简化基于云的DNS负载均衡
  • 贷齐乐案例
  • 【MATLAB源码-第249期】基于matlab的信道量化反馈的预编码仿真,采用均匀量化方式和LDL分解的预编码。
  • Unity URP无光照下Shadow 制作 <二> 合批处理
  • 探索Go语言中的列表与环形缓冲区:container/list与container/ring全解析
  • python从入门到精通:函数
  • 从零开始搭建k8s集群详细步骤
  • 搭建个人网站
  • 【Python快速入门和实践020】Python常用脚本-查看电脑基本信息