您当前的位置: 首页 >  redis

彭世瑜

暂无认证

  • 3浏览

    0关注

    2791博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

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

彭世瑜 发布时间:2022-08-15 18:06:22 ,浏览量:3

文档

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

安装

npm install redis

代码示例

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]
关注
打赏
1665367115
查看更多评论
立即登录/注册

微信扫码登录

0.0877s