问题标签 [ioredis]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
5319 浏览

node.js - 设置 ioredis 的过期时间

我正在尝试为 ioredis nodejs 中的一组值设置过期时间。我可以使用此命令将一组添加到 reids

但是我需要为这个集合设置一个过期时间。我怎样才能做到这一点?

0 投票
2 回答
20115 浏览

node.js - Redis sentinel not connect to master: Error: READONLY You can't write against a read only slave?

redis replicationsentinel建筑师有这个:

5个服务器:.1.2.3.4.5

  • .1: nodejs app, redis master, redis sentinel
  • .2: nodejs 应用程序,redis 从属
  • .3: nodejs 应用程序,redis 从属
  • .4: redis 哨兵
  • .5: redis 哨兵

Sentinel 按预期处理故障转移。 redis-cli -h x.y.z.5 -p 26379 sentinel get-master-addr-by-name mymaster总是返回.1服务器。

我连接到此复制的代码(我使用ioredis):

然后,.1nodejs app 运行正常,但是在.2and.3中,出现这个日志的错误:

P/s:我的 redis 服务器绑定了服务器 IP 和127.0.0.1. 因为,没有127.0.0.1,我遇到了这个错误:

所以,我想,我的应用程序没有连接到redis servervia sentinel,而是直接连接到localhost.

任何帮助都是合适的!

更新:当我打开时记录DEBUG=ioredis:*

更新 2:还有一件事,我在本地机器上运行应用程序,production一切都像魅力一样工作!!!

0 投票
1 回答
827 浏览

redis - 如何使用 HSCAN/redis 过滤多个模式

我试过了,ioredis但 HSCAN 只支持一个匹配模式。

从redis过滤多个模式的最佳方法是什么

0 投票
1 回答
2295 浏览

node.js - 在 Redis 上将字符串数据与压缩(缓冲)数据一起存储

有没有机会在 Redis 上将 Buffer 数据与字符串数据一起存储。

伪代码:

虽然这似乎不可能我想问。

有没有机会将压缩数据与字符串一起存储?

编辑:

将压缩数据与未压缩数据存储在同一个密钥中后,我无法解压上面的用户数据。

伪代码:

0 投票
1 回答
311 浏览

promise - ioredis bluebird 在处理程序中创建了一个承诺,但没有从它返回

有人可以向我解释为什么我收到此警告警告:在处理程序中创建了一个承诺,但在我执行以下代码时没有从它返回:

这是其余的代码:

我正在使用以下库:ioredis & bluebird。代码执行良好,一切正常!我只是不喜欢我收到无法解决的警告的事实!

0 投票
1 回答
1870 浏览

javascript - 如何创建与 Master 和 Slave 的 Redis 连接

我正在尝试进行 Redis 连接,我有一个“主”端口和两个从属端口。我想用哨兵做到这一点。

我认为连接redis的实际代码实际上已被弃用。

这是我的代码。

我正在阅读其他帖子,我认为使用 ioredis 可能会很酷。但是我对Redis了解不多...

我想与redis建立连接,如果主服务器关闭,则会自动连接到从服务器。

我希望你能帮助我,

罗斯。

0 投票
1 回答
261 浏览

javascript - How to set a value in a bitmap and retrieve a bitmap from redis using ioredis?

I would like to use a Redis bitmap to represent values.

If I have an integer value then I want to be able to set the corresponding index of the bitmap to 1 or true.

I also want to be able to retrieve the entire bitmap and walk it to identify the positions of the "ones".

There is a bitfield data structure in Redis, but I don't understand the documentation.

There are the following commands:

What is the <type> field? What value should I use for <value> (string 1?).

Finally, can anyone help me with the syntax for these commands when using ioredis?

0 投票
2 回答
3956 浏览

node.js - 使用 ioredis 向 redis 发送任意命令

是否可以使用 ioredis for Node JS 向 Redis 发送任意命令?

例如,我正在使用新的 RediSearch 模块,并希望使用以下命令创建索引:

我将如何使用 ioredis 发送此命令?

0 投票
0 回答
1069 浏览

node.js - 从 NodeJS 连接到 Redis 引发连接超时

我在 azure linux vm 中有一个 redis 服务器,在同一个 VM(A) 中运行一个 master、slave 和 sentinel。当我尝试使用 redis-cli 从另一个 VM(B) 连接到 redis sentinal 时,我能够连接并设置和获取值。但是当我尝试使用来自VM(B)的nodeJS中的ioredis模块连接到redis sentinel时,它会引发连接超时错误。我使用以下代码片段从节点应用程序连接到哨兵

令人困惑的部分是,当我在同一个 vm(A) 中运行 redis master、slave 和 sentinel 并使用 '127.0.0.1' 而不是 'xxxx' 时,代码工作正常。

任何帮助深表感谢。

0 投票
0 回答
2002 浏览

redis - Redis 集群重新分片期间集群重定向过多

Redis 版本:3.2.10

ioredis 版本:3.1.4

最近我测试了在redis集群上运行resharding操作,同时集群处于相当高的负载下,客户端使用ioredis node.js库,偶尔在客户端上我们在reshard操作期间看到以下错误。

我目前对 ioredis 的以下选项使用默认值: maxRedirections 16 retryDelayOnFailover 100ms

这是否意味着在重新分片期间,插槽数据的传输时间超过 1600 毫秒?

我大致知道迁移插槽的过程如下:

  1. 使用 CLUSTER SETSLOT IMPORTING 将目标节点槽设置为导入状态。
  2. 使用 CLUSTER SETSLOT MIGRATING 将源节点槽设置为迁移状态。
  3. 使用 CLUSTER GETKEYSINSLOT 命令从源节点获取密钥,并使用 MIGRATE 命令将它们移动到目标节点。
  4. 在源或目标中使用 CLUSTER SETSLOT NODE。

但是在上述哪些步骤中,客户端将无法获取或设置关键数据?

对于上下文,在此测试期间,每个节点的操作速度高达 100k 操作/秒。