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.

asked 3 months ago202 views
1 Answer
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
EXPERT
answered 3 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions