Changeset 444
- Timestamp:
- 01/06/08 03:07:38 (12 months ago)
- Location:
- trunk
- Files:
-
- 3 modified
-
modules/base/classes/cache.php (modified) (8 diffs)
-
modules/base/classes/cacheFacade.php (modified) (2 diffs)
-
owa_coreAPI.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/base/classes/cache.php
r437 r444 41 41 var $collections; 42 42 var $dirty_collections; 43 var $dirty_objs ;43 var $dirty_objs = array(); 44 44 var $file_perms = 0775; 45 45 var $dir_perms = 0775; … … 47 47 var $non_persistant_collections = array(); 48 48 var $mutex; 49 49 var $e; 50 50 51 51 /** … … 56 56 * @param $cache_dir string 57 57 */ 58 function __construct($cache_dir) { 59 58 function __construct($cache_dir = '') { 59 60 $this->e = &owa_coreAPI::errorSingleton(); 60 61 return $this->cache_dir = $cache_dir; 61 62 62 63 } 63 64 64 function owa_cache($cache_dir ) {65 function owa_cache($cache_dir = '') { 65 66 66 67 register_shutdown_function(array(&$this, "__destruct")); … … 90 91 if (!in_array($collection, $this->non_persistant_collections)): 91 92 $this->dirty_objs[$collection][] = $hkey; 93 //$this->debug(print_r($this->dirty_objs, true)); 92 94 $this->dirty_collections[$collection] = true; 93 95 $this->debug(sprintf('Added Object to Dirty List - Collection: %s, id: %s', $collection, $hkey)); … … 259 261 260 262 function __destruct() { 261 263 262 264 $this->persistCache(); 263 265 $this->debug($this->getStats()); … … 269 271 function persistCache() { 270 272 273 $this->debug("starting to persist cache..."); 274 271 275 // check for dirty objects 272 276 if (!empty($this->dirty_objs)): 273 277 278 $this->debug('Dirty Objects: '.print_r($this->dirty_objs, true)); 279 274 280 if ( ! $this->acquire_lock() ): 281 $this->debug("could not persist cache due to not acquiring lock."); 275 282 return false; 276 283 else: 277 284 $this->debug("starting to persist cache..."); 278 285 // make directories for collections 279 286 foreach ($this->dirty_collections as $k => $v) { … … 334 341 endif; 335 342 $this->release_lock(); 343 344 else: 345 $this->debug("There seem to be no dirty objects in the cache to persist."); 336 346 endif; 337 347 … … 369 379 function debug($msg) { 370 380 371 print $msg.'<br>';381 $this->e->debug($msg); 372 382 return; 373 383 } -
trunk/modules/base/classes/cacheFacade.php
r433 r444 32 32 require_once(OWA_BASE_CLASS_DIR.'cache.php'); 33 33 34 class owa_cacheFacade extends owa_ cache {34 class owa_cacheFacade extends owa_base { 35 35 36 var $e; 37 36 37 var $cache; 38 38 39 function __construct($cache_dir) { 40 41 // make this plugable soon 42 $this->cache = &owa_coreAPI::supportClassFactory('base', 'cache'); 43 44 if (!empty($cache_dir)): 45 $this->setCacheDir($cache_dir); 46 endif; 47 48 return; 49 } 39 50 40 $this->e = &owa_coreAPI::errorSingleton(); 41 return parent::__construct($cache_dir); 51 function owa_cacheFacade($cache_dir) { 52 53 return $this->__construct($cache_dir); 54 55 } 56 57 function get($collection, $key) { 58 59 return $this->cache->get($collection, $key); 60 61 } 62 63 function set($collection, $key, $value) { 64 65 return $this->cache->set($collection, $key, $value); 42 66 43 67 } 44 68 45 function owa_cacheFacade($cache_dir) {69 function remove($collection, $key) { 46 70 47 $this->e = &owa_coreAPI::errorSingleton();48 return $this->owa_cache($cache_dir);71 return $this->cache->remove($collection, $key); 72 } 49 73 74 function replace($collection, $key, $value) { 75 76 return $this->cache->replace($collection, $key, $value); 77 78 } 79 80 function setCacheDir($dir) { 81 82 return $this->cache->setCacheDir($dir); 83 } 84 85 function flush() { 86 87 return $this->cache->flush(); 50 88 } 51 89 … … 55 93 56 94 } 95 96 function setNonPersistantCollection($collection) { 97 98 return $this->cache->setNonPersistantCollection($collection); 99 100 } 101 102 function setGlobalCollection($collection) { 103 104 return $this->cache->setGloballCollection($collection); 105 106 } 107 57 108 58 109 function error($msg) { -
trunk/owa_coreAPI.php
r433 r444 311 311 } 312 312 313 function supportClassFactory($module, $class, $params = array()) {314 315 $obj = owa_lib::factory(OWA_BASE_DIR.DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'classes'.DIRECTORY_SEPARATOR, 'owa_', $class, $params);313 function &supportClassFactory($module, $class, $params = array()) { 314 315 $obj = &owa_lib::factory(OWA_BASE_DIR.DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'classes'.DIRECTORY_SEPARATOR, 'owa_', $class, $params); 316 316 $obj->module = $module; 317 317
