Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

thebigk's avatar
Level 13

Is it necessary to check if Redis Cache Connection is available

I'm planning to deploy my app on AWS and an important part of my configuration is the Redis Cache (through AWS ElasticCache).

I'm wondering if it's necessary to check if the Redis connection is available just before I access the cache or Laravel automatically falls back to the database?

This is how I plan to use DB -

$value = Cache::rememberForever('users', function() {
    return DB::table('users')->get();
});

In above case, will Laravel automatically access the database if the cache server is down?

0 likes
4 replies
Helmchen's avatar

I doubt it. Redis has also additional features that the database driver does not support.

Maybe there is a way, who knows, but i don't see how this should work when using cache tags or something like that :)

Just assume that redis is available, if not, you probably have bigger problems anyway.

thebigk's avatar
Level 13

@Helmchen - I'd expect the ElasticCache server to be available 99.99% of the time; but just in case the connection is refused; I need to have a fallback.

Better - is it possible to switch over to the default file based cache if Redis is not available?

msbir's avatar

Hey, did you find a solution for this issue?

Please or to participate in this conversation.