I am writing my own PHP framework (...waits for the groans to subside) for the purpose of learning (best practices, design principals etc.) as I'm entirely self-taught and consequently there are gaps in my knowledge.
I understand that most mainstream frameworks incorporate some form of caching system, which I'm guessing is for keeping regularly used classes and/or other files close by for fast loading (right?).
Ideally I envisage a system that is somewhat self monitoring and self managing in that it tracks class/file usage, memory limits and request processing performance, removing items from cache automatically when no longer needed or increasing the cache size when performance drops too low etc. (even some form of basic garbage collection is better than nothing, right?).
So my questions are:
Firstly: Have I understood everything correctly so far?
How important is it to implement this kind of system over regular include/require methods?
How can I determine memory usage and other system performance metrics?
To cache classes do I have to use the '_sleep()' and '_wakeup()' magic methods?
I also gather that to be stored a class has to be serialized. Should I use a $_SESSION variable, a temporary DB table or some kind of flat-file / SQLite DB as the cache?
Thanks for any and all help / suggestions.