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 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南