diff --git a/src/Tonic/MetadataCacheInclude.php b/src/Tonic/MetadataCacheInclude.php new file mode 100644 index 0000000..7e7f4a8 --- /dev/null +++ b/src/Tonic/MetadataCacheInclude.php @@ -0,0 +1,57 @@ +filename = $filename; + } + + /** + * Is there already cache file + * @return boolean + */ + public function isCached() + { + return is_readable($this->filename); + } + + /** + * Load the resource metadata + * @return str[] + */ + public function load() + { + return include $this->filename; + } + + /** + * Save resource metadata to disk + * @param str[] $resources Resource metadata + * @return boolean + */ + public function save($resources) + { + return file_put_contents($this->filename, 'filename); + } + + public function __toString() + { + return 'Metadata for '.count($this->load()).' resources stored in file "'.$this->filename.'" at '.date('r', filemtime($this->filename)); + } + +} diff --git a/web/dispatch.php b/web/dispatch.php index f39c858..ead40d5 100644 --- a/web/dispatch.php +++ b/web/dispatch.php @@ -15,6 +15,7 @@ #'mount' => array('Tyrell' => '/nexus'), // mount in example resources at URL /nexus #'cache' => new Tonic\MetadataCacheFile('/tmp/tonic.cache') // use the metadata cache #'cache' => new Tonic\MetadataCacheAPC // use the metadata cache + #'cache' => new Tonic\MetadataCacheInclude('/tmp/tonic-cache.php') // use the metadata cache ); $app = new Tonic\Application($config);