Jacob
Jacob

Reputation: 137

Laravel Cache (Redis) auto refresh when data is changed

I have some data in model. When data is being insert or delete how can i update the redis cache. Is there any way we can update the cache or 3rd party package

Upvotes: 0

Views: 2278

Answers (2)

Vlad Visinescu
Vlad Visinescu

Reputation: 747

The cleanest option, in my opinion, would be setting an observer on the model and updating the data.

Eloquent Observers docs: https://laravel.com/docs/5.8/eloquent#observers

Upvotes: 2

Rahul
Rahul

Reputation: 18557

You just simple need to fire command

FLUSHALL

and put data back to keys again.

The package you are looking for is

composer require predis/predis

Here is official laravel documentation for redis cache.

Upvotes: 1

Related Questions