...
|
...
|
@@ -6,6 +6,7 @@ class c_cache |
6
|
6
|
{
|
7
|
7
|
private $lock;
|
8
|
8
|
private $cacheFile;
|
|
9
|
+ private $scriptChanged;
|
9
|
10
|
|
10
|
11
|
// generiere den Cache Filename aus dem
|
11
|
12
|
// 1. script Namen
|
...
|
...
|
@@ -72,16 +73,51 @@ class c_cache |
72
|
73
|
|
73
|
74
|
$this->lock = NULL;
|
74
|
75
|
$this->cacheFile = $cacheDir . '/cache_' . $parmStr . '.html';
|
|
76
|
+
|
|
77
|
+ if (file_exists ($this->cacheFile))
|
|
78
|
+ {
|
|
79
|
+ if (filemtime ($this->cacheFile) < filemtime ($scriptFile))
|
|
80
|
+ $this->scriptChanged = TRUE;
|
|
81
|
+ else
|
|
82
|
+ {
|
|
83
|
+ $incFiles = array_unique (array_merge (
|
|
84
|
+ get_included_files (), get_required_files ()));
|
|
85
|
+
|
|
86
|
+ foreach ($incFiles as $incFile)
|
|
87
|
+ {
|
|
88
|
+ if (filemtime ($this->cacheFile) < filemtime ($incFile))
|
|
89
|
+ {
|
|
90
|
+ $this->scriptChanged = TRUE;
|
|
91
|
+ break;
|
|
92
|
+ }
|
|
93
|
+ }
|
|
94
|
+
|
|
95
|
+ $this->scriptChanged = FALSE;
|
|
96
|
+ }
|
|
97
|
+ }
|
75
|
98
|
}
|
76
|
99
|
|
77
|
100
|
|
78
|
101
|
|
79
|
102
|
function check ($interval=0)
|
80
|
103
|
{
|
|
104
|
+ $scriptFile = HOME . substr ($_SERVER['PHP_SELF'], strlen (URLPATH));
|
|
105
|
+
|
81
|
106
|
ob_start ();
|
82
|
107
|
|
|
108
|
+ if ($interval <= 0)
|
|
109
|
+ {
|
|
110
|
+ $this->lock = NULL;
|
|
111
|
+ return FALSE;
|
|
112
|
+ }
|
|
113
|
+
|
|
114
|
+ print "<pre>";
|
|
115
|
+ var_dump ($this->scriptChanged);
|
|
116
|
+ print "</pre>";
|
|
117
|
+
|
83
|
118
|
clearstatcache ();
|
84
|
|
- if (file_exists ($this->cacheFile) &&
|
|
119
|
+ if (! $this->scriptChanged &&
|
|
120
|
+ file_exists ($this->cacheFile) &&
|
85
|
121
|
time () - filemtime ($this->cacheFile) < $interval)
|
86
|
122
|
{
|
87
|
123
|
readfile ($this->cacheFile);
|
...
|
...
|
@@ -109,9 +145,12 @@ class c_cache |
109
|
145
|
function update ()
|
110
|
146
|
{
|
111
|
147
|
$page = ob_get_flush ();
|
112
|
|
- file_put_contents ($this->cacheFile, $page);
|
113
|
148
|
|
114
|
|
- releaseLock ($this->lock);
|
|
149
|
+ if ($this->lock !== NULL)
|
|
150
|
+ {
|
|
151
|
+ file_put_contents ($this->cacheFile, $page);
|
|
152
|
+ releaseLock ($this->lock);
|
|
153
|
+ }
|
115
|
154
|
}
|
116
|
155
|
};
|
117
|
156
|
|
...
|
...
|
|