O'Reilly logo

PHP 5 CMS Framework Development by Martin Brampton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Framework solution

While the motivation for a cache tends to go from the requirement down into the mechanisms, it is easier to explain the workings of cache by starting at the bottom.

Abstract cache class

We start with an abstract cache class. Although it cannot be instantiated, it provides the actual mechanisms. Since it is fairly short, it can be presented in full here:

abstract class aliroBasicCache { private static $mops = array(); protected $sizelimit = 0; protected $timeout = 0; protected function getBasePath () { return _ALIRO_SITE_BASE.'/cache/'; } abstract protected function getCachePath ($name); public function store ($object, $cachename='', $reportSizeError=true) { $path = $this->getCachePath($cachename ? $cachename : get_class($object)); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required