Skip to content

Commit

Permalink
Add pass-by-reference argument to exists() so if method returns TRUE …
Browse files Browse the repository at this point in the history
…a subsequent get() is unnecessary
  • Loading branch information
bcosca committed Nov 28, 2013
1 parent 6599502 commit a60eece
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,14 @@ function &ref($key,$add=TRUE) {
* Return TRUE if hive key is not empty (or timestamp and TTL if cached)
* @return bool
* @param $key string
* @param $val mixed
**/
function exists($key) {
$ref=&$this->ref($key,FALSE);
return isset($ref)?
TRUE:
Cache::instance()->exists($this->hash($key).'.var');
function exists($key,&$val=NULL) {
$val=&$this->ref($key,FALSE);
if (isset($val))
return TRUE;
return Cache::instance()->exists($this->hash($key).'.var',$val)?
$val:FALSE;
}

/**
Expand Down

0 comments on commit a60eece

Please sign in to comment.