当前位置:首页 > 操作系统 > MacOs

Redis在Mac下的安装和使用

1.安装Redis

官网下载:https://redis.io/download

下载稳定版本:

Redis在Mac下的安装和使用 - 文章图片

这里我下载了4.0.14版本。

 

下载完成后:

解压:tar zxf redis-4.0.14.tar.gz

安装:

cd /redis-4.0.14

sudo make install

启动服务:

cd src/redis-server

启动成功如图:

Redis在Mac下的安装和使用 - 文章图片

 

2.Redis使用

SpringBoot中整合:

在pom.xml文件中添加依赖:

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>

然后在application.yml(.properties)文件中添加Redis信息:

spring:
  redis:
    database: 0
    host: 127.0.0.1
    port: 6379
    timeout: 2000

Redis的默认端口是:6379


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!