Jump to content

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


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:



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;

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

  • 1 year later...

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

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

  • Recently Browsing   0 members

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