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

BigSpender's avatar

Laravel: generate new cache and then clean old

I am trying to regenerate cache on Laravel v. 8.9.0. The cache generates a lot of time and in this time I need to use the old. Once the new cache generated totally I want to replace by newest. I am using something: Cache::put(static::DATA_STRUCTURE, json_encode($tree))

However the cache does not refreshing. Maybe someone can provide me the answer or at least had experience regarding this subject. Many thanks.

0 likes
5 replies
Snapey's avatar

No idea what you are doing or why. I've touched probably a hundred projects and never seen or heard of such a requirement.

BigSpender's avatar

To generate new cache takes a 3 minutes. I need to keep old cache until new will be generated. Then old cache should be replaced by newest. I think in framework such a laravel it should be easy...

BigSpender's avatar

nothing wrong. I just want to replace the old cache by newest. because newest has fresh data.

Please or to participate in this conversation.