Jump to content

Data leaded from cache are different from the ones that were stored


BraseTheGreat
 Share

Recommended Posts

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:

image.png.25489505c92938cf6e8f047e6ebf63dd.png

 

Am I missing something?

 

Link to comment
Share on other sites

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):

image.png.d4c76b5faf1e8e50fb94ccb1d437b8f8.png

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

  • 1 year later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...