|
CachingLayer
#Caching in partuza IntroductionThis is a quick summary of how Caching works in Partuza. DetailsEvery data model inherits the basic Model class (library/Model.php). The model class has the automagic call function defined ... in other words for every function that doesn't exist, this function is called instead. (see http://www.php.net/manual/en/language.oop5.overloading.php for details). The call function see's if the load_function_name exists, and if the results of it are cachable (checks the $this->cachable array), if the function exists it checks to see if the results exist in cache (if it's marked as cachable), and otherwise it calls the load It also keeps track of the dependency between caching objects ... for instance a if a person's information is updated, the cached friend lists that include that person need to be invalidated (removed) too, so they get re-created with the new information.. dependency tracking is an important part of a well working caching solution, and that's included in the same Model class's caching logic. In other words it's a transparent caching layer, that requires 0 special coding to make data cachable just call your function load_my_stuff($foo, $bar) and let the Model caching layers figure out the rest for you. Special note, see the existing models for examples on how to register your cache dependencies, it's important to get this right, otherwise you get some odd results on your site. |
Sign in to add a comment