Cannot find records using redis_cli

26 Views Asked by At

I have Redis running in docker compose:

version: '3'

services:
  redis:
    image: redis:7
    container_name: my-redis
    command: redis-server --requirepass ${REDIS_PASSWORD:-REDIS_PASSWORD}
    volumes:
      - ./redis-data:/data
    ports:
      - '6379:6379'

My .env file has REDIS_PASSWORD:redis_password

I have an api that creates a record, no errors, but I cannot find the record using redis-cli.

I've tried redis-cli -a redis_password and redis-cli then 'auth redis_password`.

When I run SCAN 0 or anything I don't see any records at all. Where are they being stored? I have no idea the data can be there but I can't access it from the command line.

1

There are 1 best solutions below

1
Mouad Slimane On

By default redis contains 16 separated DB if you don't specify one when you push your data into redis Key then the database 0 is used by default First connect to CLI using this command line

redis-cli -h <your_host> -p 6379 --user <your_user> --pass <your_password>

then enter the CMD

keys *

to show all keys in the DB if their is no data you will receive (empty array) as message