1

So when I enter the redis container with: docker-compose exec redis bash, I then type: redis-cli to start redis-cli. Then, when I try to get the key (visits) I set up through Laravel app with: GET visits, it shows nil.

This is how I set up the key 'visits':

Route::get('/', function () {
    $visits = Redis::incr('visits');
    return $visits;
});

However, redis works fine in Laravel. Here's my .env:

BROADCAST_DRIVER=log
CACHE_DRIVER=redis
QUEUE_CONNECTION=database
SESSION_DRIVER=redis
SESSION_LIFETIME=120

REDIS_URL=redis
REDIS_HOST=redis #172.17.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
REDIS_CLIENT=phpredis
REDIS_CACHE_DB=0

1 Answer 1

1

Okay, I got it. It was persisted like this when I tried all keys:

127.0.0.1:6379> keys *
1) "laravel_database_laravel_cache:aEznTaRttAEmGlOd90xQX1jtvbkVEqW7bYGFhzCR"
2) "laravel_database_visits"

It's because Laravel adds a prefix from database config file.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.