0
点赞
收藏
分享

微信扫一扫

Node.js: node-redis.js客户端


文档

  • github​​https://github.com/redis/node-redis​​
  • npmjs​​https://www.npmjs.com/package/redis​​

安装

npm install

代码示例

import { createClient } from 'redis'

// 连接redis
const client = createClient({
url: 'redis://127.0.0.1:6379',
})

await client.connect()

// 设置值
await client.set('key', 'value');

// 获取值
const value = await client.get('key');
console.log(value);

// 关闭
await client.quit()

连接格式

redis[s]://[[username][:password]@][host][:port][/db-number]


举报

相关推荐

0 条评论