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>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…