Skip to content
/ FullStack/Redis
3/4/2024
1m
AI 摘要

本文介绍了 Redis 的基本概念、安装启动方法及在 NodeJs 中的连接方式,包括使用 redisioredis 库的示例代码,突出其作为高性能 key-value 数据库的特点。

Redis

Redis 是完全开源的,遵守 BSD 协议,是一个高性能的 key-value 数据库

基础用法

安装和启动

$ brew install redis        # 安装
$ brew services start redis # 启动
$ brew services stop redis  # 停止

使用

 redis-cli
127.0.0.1:6379> SET mykey "hello world"
OK
127.0.0.1:6379> GET mykey
"hello world"
127.0.0.1:6379>

NodeJs 连接

在 NodeJs 中,可以使用 redis/node-redis 进行连接

$ npm i redis

或者使用另一个也很流行的库 redis/ioredis

比较:NPM Redis VS Ioredis | A Comparative Post

Released under the MIT License.