Answer the question
In order to leave comments, you need to log in
Proper storage of objects in php?
I want to cache the results of the work of a heavy class. but it is not clear how to correctly store a frequently used object (returned from a class method) in the cache (file cache, that is, I would like to save the object in a string). tried serialization, but in object protection.
public function __wakeup() {
trigger_error('Unserializing is not allowed.', E_USER_ERROR);
}
Answer the question
In order to leave comments, you need to log in
Resolved (case, not object storage in php) Firstly, I realized that storing the entire object is expensive. It's easier to write a wrapper for the data you really need and store it, for example, in an array. Secondly, having carefully studied the object again, I found the methods already implemented there for serialization (json).
How to store objects is now more academic than practical interest.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question