ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

core_cache.php
Go to the documentation of this file.
1 <?php
2
3 /*
4 * This source code is a part of the Ultimix Project.
5 * It is distributed under BSD license. All other third side source code (like tinyMCE) is distributed under
6 * it's own license wich could be found from the corresponding files or sources.
7 * This source code is provided "as is" without any warranties or garanties.
8 *
9 * Have a nice day!
10 *
11 * @url http://ultimix.sorceforge.net
12 *
13 * @author Alexey "gdever" Dodonov
14 */
15
26 class core_cache{
27
28 var $FilePrefix = false;
29
30 function _load_root_dir_cache( $Dirname )
31 {
32 $Data = @file_get_contents( $Dirname.'/../../data/'.$this->FilePrefix.'_root_dir_cache' );
33 if( $Data !== false )
34 {
35 global $RootDirCache;
36 $RootDirCache = unserialize( $Data );
37 }
38 }
39
40 function _load_package_real_version_cache( $Dirname )
41 {
42 $Data = @file_get_contents( $Dirname.'/../../data/'.$this->FilePrefix.'_package_real_version_cache' );
43 if( $Data !== false )
44 {
45 global $PackageRealVersionCache;
46 $PackageRealVersionCache = unserialize( $Data );
47 }
48 }
49
50 function _load_rewrited_package_cache( $Dirname )
51 {
52 $Data = @file_get_contents( $Dirname.'/../../data/'.$this->FilePrefix.'_rewrited_package_cache' );
53 if( $Data !== false )
54 {
55 global $RewritedPackageCache;
56 $RewritedPackageCache = unserialize( $Data );
57 }
58 }
59
60 function _load_rewrites_cache( $Dirname )
61 {
62 $Data = @file_get_contents( $Dirname.'/../../data/'.$this->FilePrefix.'_rewrites_cache' );
63 if( $Data !== false )
64 {
65 global $RewritesCache;
66 $RewritesCache = unserialize( $Data );
67 }
68 }
69
70 function _load_package_path_cache( $Dirname )
71 {
72 $Data = @file_get_contents( $Dirname.'/../../data/'.$this->FilePrefix.'_package_path_cache' );
73 if( $Data !== false )
74 {
75 global $PackagePathCache;
76 $PackagePathCache = unserialize( $Data );
77 }
78 }
79
80 function _load_package_relative_path_cache( $Dirname )
81 {
82 $Data = @file_get_contents( $Dirname.'/../../data/'.$this->FilePrefix.'_package_relative_path_cache' );
83 if( $Data !== false )
84 {
85 global $PackageRelativePathCache;
86 $PackageRelativePathCache = unserialize( $Data );
87 }
88 }
89
90 function _load_top_package_name_cache( $Dirname )
91 {
92 $Data = @file_get_contents( $Dirname.'/../../data/'.$this->FilePrefix.'_top_package_name_cache' );
93 if( $Data !== false )
94 {
95 global $TopPackageNameCache;
96 $TopPackageNameCache = unserialize( $Data );
97 }
98 }
99
100 function _load_make_full_version_cache( $Dirname )
101 {
102 $Data = @file_get_contents( $Dirname.'/../../data/'.$this->FilePrefix.'_make_full_version_cache' );
103 if( $Data !== false )
104 {
105 global $MakeFullVersionCache;
106 $MakeFullVersionCache = unserialize( $Data );
107 }
108 }
109
110 function _load_full_class_name_cache( $Dirname )
111 {
112 $Data = @file_get_contents( $Dirname.'/../../data/'.$this->FilePrefix.'_full_class_name_cache' );
113 if( $Data !== false )
114 {
115 global $FullClassNameCache;
116 $FullClassNameCache = unserialize( $Data );
117 }
118 }
119
120 function _load_get_package_cache( $Dirname )
121 {
122 $Data = @file_get_contents( $Dirname.'/../../data/'.$this->FilePrefix.'_get_package_cache' );
123 if( $Data !== false )
124 {
125 global $GetPackageCache;
126 $GetPackageCache = unserialize( $Data );
127 }
128 }
129
130 function _load_package_script_paths_cache( $Dirname )
131 {
132 $Data = @file_get_contents( $Dirname.'/../../data/'.$this->FilePrefix.'_package_script_paths_cache' );
133 if( $Data !== false )
134 {
135 global $PackagePathsCache;
136 $PackagePathsCache = unserialize( $Data );
137 }
138 }
139
150 function __construct()
151 {
152 $this->FilePrefix = md5( $_SERVER[ 'SCRIPT_FILENAME' ] );
153 $Dirname = dirname( __FILE__ );
154
155 $this->_load_root_dir_cache( $Dirname );
156 $this->_load_package_real_version_cache( $Dirname );
157 $this->_load_rewrited_package_cache( $Dirname );
158 $this->_load_rewrites_cache( $Dirname );
159 $this->_load_package_path_cache( $Dirname );
160 $this->_load_package_relative_path_cache( $Dirname );
161 $this->_load_top_package_name_cache( $Dirname );
162 $this->_load_make_full_version_cache( $Dirname );
163 $this->_load_full_class_name_cache( $Dirname );
164 $this->_load_get_package_cache( $Dirname );
165 $this->_load_package_script_paths_cache( $Dirname );
166 }
167
178 function drop_core_cache()
179 {
180 $Dirname = dirname( __FILE__ );
181
182 $Files = array(
183 $this->FilePrefix.'_root_dir_cache' , $this->FilePrefix.'_package_real_version_cache' ,
184 $this->FilePrefix.'_rewrited_package_cache' , $this->FilePrefix.'_rewrites_cache' ,
185 $this->FilePrefix.'_package_path_cache' , $this->FilePrefix.'_package_relative_path_cache' ,
186 $this->FilePrefix.'_top_package_name_cache' , $this->FilePrefix.'_make_full_version_cache' ,
187 $this->FilePrefix.'_full_class_name_cache' , $this->FilePrefix.'_get_package_cache' ,
188 $this->FilePrefix.'_package_script_paths_cache'
189 );
190
191 foreach( $Files as $i => $File )
192 {
193 @unlink( $Dirname.'/../../data/'.$File );
194 }
195 }
196
197 function _save_root_dir_cache( $Dirname )
198 {
199 global $RootDirCacheChanged;
200 if( $RootDirCacheChanged )
201 {
202 global $RootDirCache;
203 file_put_contents(
204 $Dirname.'/../../data/'.$this->FilePrefix.'_root_dir_cache' ,
205 serialize( $RootDirCache )
206 );
207 }
208 }
209
210 function _save_package_real_version_cache( $Dirname )
211 {
212 global $PackageRealVersionCacheChanged;
213 if( $PackageRealVersionCacheChanged )
214 {
215 global $PackageRealVersionCache;
216 file_put_contents(
217 $Dirname.'/../../data/'.$this->FilePrefix.'_package_real_version_cache' ,
218 serialize( $PackageRealVersionCache )
219 );
220 }
221 }
222
223 function _save_rewrited_package_cache( $Dirname )
224 {
225 global $RewritedPackageCacheChanged;
226 if( $RewritedPackageCacheChanged )
227 {
228 global $RewritedPackageCache;
229 file_put_contents(
230 $Dirname.'/../../data/'.$this->FilePrefix.'_rewrited_package_cache' ,
231 serialize( $RewritedPackageCache )
232 );
233 }
234 }
235
236 function _save_rewrites_cache( $Dirname )
237 {
238 global $RewritesCacheChanged;
239 if( $RewritesCacheChanged )
240 {
241 global $RewritesCache;
242 file_put_contents(
243 $Dirname.'/../../data/'.$this->FilePrefix.'_rewrites_cache' ,
244 serialize( $RewritesCache )
245 );
246 }
247 }
248
249 function _save_package_path_cache( $Dirname )
250 {
251 global $PackagePathCacheChanged;
252 if( $PackagePathCacheChanged )
253 {
254 global $PackagePathCache;
255 file_put_contents(
256 $Dirname.'/../../data/'.$this->FilePrefix.'_package_path_cache' ,
257 serialize( $PackagePathCache )
258 );
259 }
260 }
261
262 function _save_package_relative_path_cache( $Dirname )
263 {
264 global $PackageRelativePathCacheChanged;
265 if( $PackageRelativePathCacheChanged )
266 {
267 global $PackageRelativePathCache;
268 file_put_contents(
269 $Dirname.'/../../data/'.$this->FilePrefix.'_package_relative_path_cache' ,
270 serialize( $PackageRelativePathCache )
271 );
272 }
273 }
274
275 function _save_top_package_name_cache( $Dirname )
276 {
277 global $TopPackageNameCacheChanged;
278 if( $TopPackageNameCacheChanged )
279 {
280 global $TopPackageNameCache;
281 file_put_contents(
282 $Dirname.'/../../data/'.$this->FilePrefix.'_top_package_name_cache' ,
283 serialize( $TopPackageNameCache )
284 );
285 }
286 }
287
288 function _save_make_full_version_cache( $Dirname )
289 {
290 global $MakeFullVersionCacheChanged;
291 if( $MakeFullVersionCacheChanged )
292 {
293 global $MakeFullVersionCache;
294 file_put_contents(
295 $Dirname.'/../../data/'.$this->FilePrefix.'_make_full_version_cache' ,
296 serialize( $MakeFullVersionCache )
297 );
298 }
299 }
300
301 function _save_full_class_name_cache( $Dirname )
302 {
303 global $FullClassNameCacheChanged;
304 if( $FullClassNameCacheChanged )
305 {
306 global $FullClassNameCache;
307 file_put_contents(
308 $Dirname.'/../../data/'.$this->FilePrefix.'_full_class_name_cache' ,
309 serialize( $FullClassNameCache )
310 );
311 }
312 }
313
314 function _save_get_package_cache( $Dirname )
315 {
316 global $GetPackageCacheChanged;
317 if( $GetPackageCacheChanged )
318 {
319 global $GetPackageCache;
320 file_put_contents(
321 $Dirname.'/../../data/'.$this->FilePrefix.'_get_package_cache' ,
322 serialize( $GetPackageCache )
323 );
324 }
325 }
326
327 function _save_package_script_paths_cache( $Dirname )
328 {
329 global $PackagePathsCacheChanged;
330 if( $PackagePathsCacheChanged )
331 {
332 global $PackagePathsCache;
333 file_put_contents(
334 $Dirname.'/../../data/'.$this->FilePrefix.'_package_script_paths_cache' ,
335 serialize( $PackagePathsCache )
336 );
337 }
338 }
339
350 function __destruct()
351 {
352 $Dirname = dirname( __FILE__ );
353
354 $this->_save_root_dir_cache( $Dirname );
355 $this->_save_package_real_version_cache( $Dirname );
356 $this->_save_rewrited_package_cache( $Dirname );
357 $this->_save_rewrites_cache( $Dirname );
358 $this->_save_package_path_cache( $Dirname );
359 $this->_save_package_relative_path_cache( $Dirname );
360 $this->_save_top_package_name_cache( $Dirname );
361 $this->_save_make_full_version_cache( $Dirname );
362 $this->_save_full_class_name_cache( $Dirname );
363 $this->_save_get_package_cache( $Dirname );
364 $this->_save_package_script_paths_cache( $Dirname );
365 }
366 }
367
368 global $CoreCache;
369 $CoreCache = new core_cache();
370
381 function _drop_core_cache()
382 {
383 global $CoreCache;
384 $CoreCache->drop_cache();
385 }
386 ?>