Changeset 152 for trunk/services/admins.php
- Timestamp:
- Jun 7, 2006 5:35:16 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/services/admins.php
r147 r152 30 30 $fv = new FormValidator(); 31 31 32 $cache =& Cache::getInstance(); 32 // Configure the prefs object. 33 $prefs =& Prefs::getInstance('admins'); 34 $prefs->setParam(array('persistent' => false)); 35 36 // Configure the cache object. 37 $cache =& Cache::getInstance('admins'); 38 $cache->setParam(array('enable' => true)); 33 39 34 40 // Instantiate a sorting object with the default sort and order. Add SQL for each column. … … 70 76 71 77 if (getFormData('break_list_cache', false)) { 72 // Break the cache because we are changing thelist data.73 $cache->delete( $_SERVER['PHP_SELF']);78 // Remove any stale cached list data. 79 $cache->delete('list'); 74 80 } 75 81 … … 319 325 $app =& App::getInstance(); 320 326 $db =& DB::getInstance(); 321 $cache =& Cache::getInstance( );327 $cache =& Cache::getInstance('admins'); 322 328 323 329 $lock->select('admin_tbl', 'admin_id', $id); … … 326 332 } 327 333 328 // Break the cache because we are changing thelist data.329 $cache->delete( $_SERVER['PHP_SELF']);334 // Remove any stale cached list data. 335 $cache->delete('list'); 330 336 331 337 // Get the information for this object. … … 367 373 $app =& App::getInstance(); 368 374 $db =& DB::getInstance(); 369 $cache =& Cache::getInstance( );375 $cache =& Cache::getInstance('admins'); 370 376 371 // Break the cache because we are changing thelist data.372 $cache->delete( $_SERVER['PHP_SELF']);377 // Remove any stale cached list data. 378 $cache->delete('list'); 373 379 374 380 // Insert record data. … … 411 417 $app =& App::getInstance(); 412 418 $db =& DB::getInstance(); 413 $cache =& Cache::getInstance( );419 $cache =& Cache::getInstance('admins'); 414 420 415 421 $lock->select('admin_tbl', 'admin_id', $frm['admin_id']); … … 418 424 } 419 425 420 // Break the cache because we are changing thelist data.421 $cache->delete( $_SERVER['PHP_SELF']);426 // Remove any stale cached list data. 427 $cache->delete('list'); 422 428 423 429 // If the userpass is left blank or with the filler **** characters, we don't want to update it. … … 455 461 global $so; 456 462 $db =& DB::getInstance(); 457 $prefs =& Prefs::getInstance( );458 $cache =& Cache::getInstance( );463 $prefs =& Prefs::getInstance('admins'); 464 $cache =& Cache::getInstance('admins'); 459 465 460 466 $where_clause = ''; … … 501 507 "; 502 508 509 // Use a cash hash to determine if the result-set has changed. 503 510 // A unique key for this query, with the total_items in case db records 504 511 // were added since the last cache. This identifies a unique set of … … 507 514 // without knowing the hash. 508 515 $cache_hash = md5($sql . '|' . $page->total_items); 509 if ($prefs->get('cache_hash', $_SERVER['PHP_SELF']) != $cache_hash) { 510 $cache->delete($_SERVER['PHP_SELF']); 511 $prefs->set('cache_hash', $cache_hash, $_SERVER['PHP_SELF']); 512 } 513 514 if ($cache->exists($_SERVER['PHP_SELF']) && false) { 515 // Get the cached results. 516 $list = $cache->get($_SERVER['PHP_SELF']); 517 } else { 518 // If the list is not already cached, query now. 519 $qid = $db->query($sql); 520 // Fill an array with the items for this page. 521 while ($row = mysql_fetch_assoc($qid)) { 522 $list[] = $row; 523 } 524 525 if (isset($list) && !empty($list)) { 526 // Cache the results. 527 $cache->set($list, $_SERVER['PHP_SELF']); 528 } 516 if ($prefs->get('cache_hash') != $cache_hash) { 517 $cache->delete('list'); 518 $prefs->set('cache_hash', $cache_hash); 519 } 520 521 // First try to return from the cache. 522 if ($cache->exists('list')) { 523 return $cache->get('list'); 524 } 525 526 // The list was not cached, so issue the real query. 527 $qid = $db->query($sql); 528 while ($row = mysql_fetch_assoc($qid)) { 529 $list[] = $row; 530 } 531 532 // Save this list into the cache. 533 if (isset($list) && !empty($list)) { 534 $cache->set('list', $list); 529 535 } 530 536
Note: See TracChangeset
for help on using the changeset viewer.