You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two instances of the same object (i.e. $obj1 === $obj2) if stored and then fetched from cache should be the same instance again.
classA {}
$obj1 = newA();
$obj2 = $obj1;
var_dump($obj1 === $obj2); // true
apcu_store('obj1', $obj1);
apcu_store('obj2', $obj2);
var_dump(apcu_fetch('obj1') === apcu_fetch('obj2')); // false, but should be true
Semi-real use case:
classUser {}
classPost {
public$createdBy;
public$editedBy;
}
$user = newUser();
$post = newPost();
$post->createdBy = $user;
$post->editedBy = $user;
// persist $post to DB// ...// hydrate $post from DB and cache it
apcu_store('post', $post);
// ...// fetch $post from cache$post = apcu_fetch('post');
// now $post->createdBy and $post->editedBy are two different instances of class User, but they should be the same instance as the original
The text was updated successfully, but these errors were encountered:
Two instances of the same object (i.e.
$obj1 === $obj2
) if stored and then fetched from cache should be the same instance again.Semi-real use case:
The text was updated successfully, but these errors were encountered: