BraseTheGreat Posted December 9, 2021 Share Posted December 9, 2021 Hello community, I have a simple code: $fulldays = $cache->get('fulldays', 60, function() { $firstDayOfWeek = strtotime("monday -1 week"); $value = serviceGetFullDaysOld($firstDayOfWeek,21); // get full data from this monday for 21 days bd($value); //! First DUMP return $value; }); bd($cache->get('fulldays')); //! Second DUMP So two dumps in the code. Structure of dumped data is quite the same, but second dump (from cache) is missing data from attribute Activities: Am I missing something? Link to comment Share on other sites More sharing options...
BraseTheGreat Posted December 9, 2021 Author Share Posted December 9, 2021 Ok, maybe I am starting to understand. I replicated the problem here in much easier scenario: $home = $cache->get('home', 60, function() { $home = wire()->pages->get("/"); $home->custom_property = "Value"; return $home; }); bd($home); With these results (before and after cache): It seams that before save to cache, all object are transformed to some string/basic structure. Is there an option how to save to cache anything without any transformation regardless the type ob object? Link to comment Share on other sites More sharing options...
BraseTheGreat Posted December 9, 2021 Author Share Posted December 9, 2021 Another clue: I looked to DB how the pages are saved: I thought that all data will be saved, but now I see that only IDs are present. Now it makes perfect sense, why there is data loss. Is there a way how to store all data from PageArray? Link to comment Share on other sites More sharing options...
bernhard Posted February 23, 2023 Share Posted February 23, 2023 It might be too late but this would work: $array = $pages->findRaw("id>0,limit=3", "title, created"); db($array, 'array'); $wire->cache->save('test', $array); db($wire->cache->get('test'), 'cache'); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now