I have a very heavy class definition that’s MySQL dependent (i.e. can be slow sometimes).
I’ve successfully installed and started using Memcache library in PHP. This allows me to store entire objects without having to re-query them.
However, I’ve extended my class to auto update the database of any changes. I use __get and __set to track changes, and then update on __destruct
What I cannot figure out how to test is whether __destruct is called when Memcache deletes the object.
Any one know for a fact / have a suggestion on how to test it?
No, memcache will not destruct the object. You’re object is constantly
__sleep()‘ing and__wakeup()‘ing. But since PHP is not the one destroying or losing the object the destructor is never called. There’s an outside chance your caching library is removing the object from memcache after it’s expired and destroying the object thus calling__destruct().. but that would depend on the implementation.