Development

Changeset 6362

You must first sign up to be able to contribute.

Changeset 6362

Show
Ignore:
Timestamp:
12/07/07 15:34:07 (7 months ago)
Author:
fabien
Message:

small refactoring of the cache framework

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/cache/sfAPCCache.class.php

    r4586 r6362  
    5757  public function has($key) 
    5858  { 
    59     return false === apc_fetch($this->prefix.$key) ? false : true
     59    return !(false === apc_fetch($this->prefix.$key))
    6060  } 
    6161 
  • trunk/lib/cache/sfEAcceleratorCache.class.php

    r6361 r6362  
    5757  public function has($key) 
    5858  { 
    59     return null === eaccelerator_get($this->prefix.$key) ? false : true
     59    return !is_null(eaccelerator_get($this->prefix.$key))
    6060  } 
    6161 
     
    102102  public function clean($mode = sfCache::ALL) 
    103103  { 
    104     if (sfCache::OLD == $mode) 
     104    if (sfCache::OLD === $mode) 
    105105    { 
    106106      return eaccelerator_gc(); 
  • trunk/lib/cache/sfMemcacheCache.class.php

    r5223 r6362  
    103103  public function has($key) 
    104104  { 
    105     return false === $this->memcache->get($this->prefix.$key) ? false : true
     105    return !(false === $this->memcache->get($this->prefix.$key))
    106106  } 
    107107 
  • trunk/lib/cache/sfXCacheCache.class.php

    r6215 r6362  
    6464  { 
    6565    $lifetime = $this->getLifetime($lifetime); 
     66 
    6667    return xcache_set($this->prefix.$key, str_pad(time() + $lifetime, 12, 0, STR_PAD_LEFT).$data, $lifetime); 
    6768  } 
     
    8081  public function clean($mode = sfCache::ALL) 
    8182  { 
    82     if ($mode != sfCache::ALL) 
     83    if ($mode !== sfCache::ALL) 
    8384    { 
    8485      return true; 
  • trunk/test/unit/cache/sfAPCCacheTest.php

    r4957 r6362  
    1414$t = new lime_test($plan, new lime_output_color()); 
    1515 
    16 if (!function_exists('apc_store')) 
     16try 
    1717{ 
    18   $t->skip('APC needed to run these tests', $plan); 
     18  new sfAPCCache(); 
     19
     20catch (sfInitializationException $e) 
     21
     22  $t->skip($e->getMessage(), $plan); 
    1923  return; 
    2024} 
  • trunk/test/unit/cache/sfEAcceleratorCacheTest.php

    r6361 r6362  
    1616try 
    1717{ 
    18   $cache = new sfEAcceleratorCache(); 
     18  new sfEAcceleratorCache(); 
    1919} 
    2020catch (sfInitializationException $e) 
    2121{ 
    2222  $t->skip($e->getMessage(), $plan); 
     23  return; 
    2324} 
    2425 
  • trunk/test/unit/cache/sfSQLiteCacheTest.php

    r4957 r6362  
    1515$t = new lime_test($plan, new lime_output_color()); 
    1616 
    17 if (!extension_loaded('SQLite')) 
     17try 
    1818{ 
    19   $t->skip('APC needed to run these tests', $plan); 
     19  new sfSQLiteCache(array('database' => ':memory:')); 
     20
     21catch (sfInitializationException $e) 
     22
     23  $t->skip($e->getMessage(), $plan); 
    2024  return; 
    2125} 
  • trunk/test/unit/cache/sfXCacheCacheTest.php

    r4957 r6362  
    1414$t = new lime_test($plan, new lime_output_color()); 
    1515 
    16 if (!function_exists('xcache_set')) 
     16try 
    1717{ 
    18   $t->skip('XCache needed to run these tests', $plan); 
     18  new sfXCacheCache(); 
     19
     20catch (sfInitializationException $e) 
     21
     22  $t->skip($e->getMessage(), $plan); 
    1923  return; 
    2024}