I am using cache to store data structure from database:
Cache::forever(static::DATA_STRUCTURE, json_encode($tree));
However before I generate there should cleaned old:
Artisan::call('cache:clear');
But generating new cache takes some time and I want to store old cache until new will be generated.
I am using typical file cache. Does anyone can provide some hint? Maybe we can do it from the box or some package.
At this moment I see only one solution: just generate in some other folder and remove old folder with cache, then move new instead the old.
2
Answers
I just decided my problem by following way: just pushed data in variables and the cleaned cache by tag, then pushed new data to this tag. Thanks!
As Maksim said you can use
Cache::put
, but also you can set the temp values something like this