Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.5k views
in Technique[技术] by (71.8m points)

laravel - Why my Redis Docker container shows "(empty array)" for KEYS * while I'm absolutely sure it has cached data and it works OK

This is chunk of my docker-compose.yml:

  redis:
    image: redis:alpine
    container_name: foo_redis
    volumes:
      - ./docker/volumes/redis:/data
    restart: unless-stopped
    ports:
      - 6379:6379
    networks:
      - local_network

I can guarantee that data persists between ups and downs because I've defined volumes.

I can prove that data is being stored physically because I see dump.rdb within ./docker/volumes/redis on my host machine.

  • When I enable debugbar I can see that route where I cache stuff has no queries.
  • When I clear Laravel's cache and refresh page I see number of DB queries, second refresh - no queries. Clearly it works with no issues.

Then from my host machine I do:

docker exec -it foo_redis redis-cli

I get a prompt:

127.0.0.1:6379>

I type KEYS * and I get:

127.0.0.1:6379> KEYS *
(empty array)
127.0.0.1:6379>

Why? What am I doing wrong? Redis seems to works fine. My Laravel app has predis and caching works with no issues.

edit:

My .env looks like:

CACHE_DRIVER=redis
REDIS_CLIENT=predis
REDIS_HOST=redis
REDIS_PASSWORD=null
REDIS_PORT=6379

edit 2:

When I manually put something into redis, it shows only that thing.

127.0.0.1:6379> set hello world
OK
127.0.0.1:6379> get hello
"world"
127.0.0.1:6379> KEYS *
1) "hello"
127.0.0.1:6379>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...