掃二維碼與項(xiàng)目經(jīng)理溝通
我們?cè)谖⑿派?4小時(shí)期待你的聲音
解答本文疑問(wèn)/技術(shù)咨詢/運(yùn)營(yíng)咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流
哈嘍,大家好,我是指北君。

目前創(chuàng)新互聯(lián)建站已為1000+的企業(yè)提供了網(wǎng)站建設(shè)、域名、虛擬空間、網(wǎng)站托管、服務(wù)器托管、企業(yè)網(wǎng)站設(shè)計(jì)、陵水黎族網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長(zhǎng),共同發(fā)展。
本篇文件我們來(lái)介紹如何用Springboot整合Redis。
docker pull redis:6.2.6
mkdir -p /mydata/redis/conf
touch /mydata/redis/conf/redis.conf
# 啟動(dòng) 同時(shí) 映射到對(duì)應(yīng)文件夾
# 后面 \ 代表?yè)Q行
docker run -p 6379:6379 --name redis \
-v /mydata/redis/data:/data \
-v /mydata/redis/conf/redis.conf:/etc/redis/redis.conf \
-d redis:6.2.6 redis-server /etc/redis/redis.conf
docker exec -it redis redis-cli
注意:新版本redis6.0 默認(rèn)開(kāi)啟了混合持久化,重啟之后依然可以看到重啟之前插入的數(shù)據(jù)。
配置文件地址如下:
https://raw.githubusercontent.com/redis/redis/6.2/redis.conf
https://github.com/uglide/RedisDesktopManager
下載并安裝,然后連接到我們安裝的 Redis,可以看到我們插入的數(shù)據(jù)。
之前已經(jīng)通過(guò) docker 安裝好了 Redis。
pom.xml
org.springframework.boot
spring-boot-starter-data-redis
application.yml
spring:
redis:
host: 192.168.88.14
port: 6379
@Autowired
StringRedisTemplate stringRedisTemplate;
@Test
public void testStringRedisTemplate() {
stringRedisTemplate.opsForValue().set("hello","world_" + UUID.randomUUID().toString());
String hello = stringRedisTemplate.opsForValue().get("hello");
System.out.println("保存的數(shù)據(jù)是:" + hello);
}

我們?cè)谖⑿派?4小時(shí)期待你的聲音
解答本文疑問(wèn)/技術(shù)咨詢/運(yùn)營(yíng)咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流
微信二維碼
Copyright © 2002-2023 uogjgqi.cn 快上網(wǎng)建站品牌 QQ:244261566 版權(quán)所有 備案號(hào):蜀ICP備19037934號(hào)
微信二維碼
移動(dòng)版官網(wǎng)