summaryrefslogtreecommitdiffstatshomepage
path: root/src/SemanticScuttle/Service/Cache.php
diff options
context:
space:
mode:
authorGravatar cweiske2009-10-03 14:08:25 +0000
committerGravatar cweiske2009-10-03 14:08:25 +0000
commitb7345f833dea849e94f2ce23fdbe6ab58ba98be3 (patch)
treeb6b6d73910e69621824e0fb46bcaa81d08607052 /src/SemanticScuttle/Service/Cache.php
parent29422fa55379aa61a61019b832c83dab6d450264 (diff)
downloadscuttle-b7345f833dea849e94f2ce23fdbe6ab58ba98be3.tar.gz
scuttle-b7345f833dea849e94f2ce23fdbe6ab58ba98be3.zip
more file renamings
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@387 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'src/SemanticScuttle/Service/Cache.php')
-rw-r--r--src/SemanticScuttle/Service/Cache.php38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/SemanticScuttle/Service/Cache.php b/src/SemanticScuttle/Service/Cache.php
new file mode 100644
index 0000000..fe66d38
--- /dev/null
+++ b/src/SemanticScuttle/Service/Cache.php
@@ -0,0 +1,38 @@
+<?php
+class CacheService {
+ var $basedir;
+ var $fileextension = '.cache';
+
+ function &getInstance() {
+ static $instance;
+
+ if (!isset($instance))
+ $instance =& new CacheService();
+
+ return $instance;
+ }
+
+ function CacheService() {
+ $this->basedir = $GLOBALS['dir_cache'];
+ }
+
+ function Start($hash, $time = 300) {
+ $cachefile = $this->basedir .'/'. $hash . $this->fileextension;
+ if (file_exists($cachefile) && time() < filemtime($cachefile) + $time) {
+ @readfile($cachefile);
+ echo "\n<!-- Cached: ". date('r', filemtime($cachefile)) ." -->\n";
+ unset($cachefile);
+ exit;
+ }
+ ob_start("ob_gzhandler");
+ }
+
+ function End($hash) {
+ $cachefile = $this->basedir .'/'. $hash . $this->fileextension;
+ $handle = fopen($cachefile, 'w');
+ fwrite($handle, ob_get_contents());
+ fclose($handle);
+ ob_flush();
+ }
+}
+?> \ No newline at end of file