unable to see data on the redis cluster but can fetch via redis-adapter client in node js

0

hi, i am connecting to the elasticache redis cluster and setting getting data using below code: pubClient = createClient({host: <redis-cluster-endpoint>,port: 6379,tls: {rejectUnauthorized: false} await pubClient.hGetAll('customHashName') is giving me an object with 2 records. but scan 0 gives me empty array when i connect to the redis cluster via ec2 terminal where i have installed redis-cli. i am using correct values everywhere for connecting but still can't see the data in redis-cli. my redis cluster is serverless.

已提问 2 个月前196 查看次数
1 回答
0

There could be a few reasons why you are not able to see the data in Redis CLI that you are able to retrieve via the Node.js code:

  • The Redis CLI connection is not pointing to the same endpoint as the Node.js client. Make sure the Redis CLI is connecting to the same endpoint as the primary node of the Redis cluster.
  • The data is stored on a different shard/node than where the Redis CLI is connected. Redis cluster partitions the data across multiple nodes/shards. The CLI may be connected to a different node/shard than where the key exists.
  • The Redis CLI is not configured to connect to a Redis cluster. For a cluster setup, Redis CLI needs to be compiled with cluster mode enabled.

Having said that, please check these:

  • Connect Redis CLI to the same endpoint as the primary node using
redis-cli -c -h <redis-cluster-endpoint> -p 6379
  • Use Redis CLI CLUSTER commands like
 CLUSTER NODES

to check cluster configuration and nodes,

 CLUSTER KEYSLOT

to identify shard for the key

  • Recompile Redis CLI with cluster mode enabled if not already done so.
profile picture
专家
已回答 2 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则