Skip to content
This repository has been archived by the owner on Feb 20, 2024. It is now read-only.

Commit

Permalink
general cleanup & adding the set() method
Browse files Browse the repository at this point in the history
  • Loading branch information
tomschlick committed May 3, 2011
1 parent 95b2690 commit 9dde1c0
Showing 1 changed file with 48 additions and 7 deletions.
55 changes: 48 additions & 7 deletions libraries/memcached_library.php
Expand Up @@ -116,11 +116,53 @@ public function add($key = NULL, $value = NULL, $expiration = NULL)
case 'Memcache': case 'Memcache':
$add_status = $this->m->add($this->key_name($key), $value, $this->config['config']['compression'], $expiration); $add_status = $this->m->add($this->key_name($key), $value, $this->config['config']['compression'], $expiration);
break; break;

default:
case 'Memcached': case 'Memcached':
$add_status = $this->m->add($this->key_name($key), $value, $expiration); $add_status = $this->m->add($this->key_name($key), $value, $expiration);
break; break;
}

return $add_status;
}
}

/*
+-------------------------------------+
Name: set
Purpose: similar to the add() method but uses set
@param return : TRUE or FALSE
+-------------------------------------+
*/
public function set($key = NULL, $value = NULL, $expiration = NULL)
{
if(is_null($expiration))
{
$expiration = $this->config['config']['expiration'];
}
if(is_array($key))
{
foreach($key as $multi)
{
if(!isset($multi['expiration']) || $multi['expiration'] == '')
{
$multi['expiration'] = $this->config['config']['expiration'];
}
$this->set($this->key_name($multi['key']), $multi['value'], $multi['expiration']);
}
}
else
{
$this->local_cache[$this->key_name($key)] = $value;
switch($this->client_type)
{
case 'Memcache':
$add_status = $this->m->set($this->key_name($key), $value, $this->config['config']['compression'], $expiration);
break;

default: default:
$add_status = $this->m->add($this->key_name($key), $value, $expiration); case 'Memcached':
$add_status = $this->m->set($this->key_name($key), $value, $expiration);
break; break;
} }


Expand Down Expand Up @@ -233,10 +275,9 @@ public function replace($key = NULL, $value = NULL, $expiration = NULL)
case 'Memcache': case 'Memcache':
$replace_status = $this->m->replace($this->key_name($key), $value, $this->config['config']['compression'], $expiration); $replace_status = $this->m->replace($this->key_name($key), $value, $this->config['config']['compression'], $expiration);
break; break;
case 'Memcached':
$replace_status = $this->m->replace($this->key_name($key), $value, $expiration);
break;
default: default:
case 'Memcached':
$replace_status = $this->m->replace($this->key_name($key), $value, $expiration); $replace_status = $this->m->replace($this->key_name($key), $value, $expiration);
break; break;
} }
Expand Down Expand Up @@ -284,10 +325,9 @@ public function getstats($type="items")
case 'Memcache': case 'Memcache':
$stats = $this->m->getStats($type); $stats = $this->m->getStats($type);
break; break;
case 'Memcached':
$stats = $this->m->getStats();
break;
default: default:
case 'Memcached':
$stats = $this->m->getStats(); $stats = $this->m->getStats();
break; break;
} }
Expand All @@ -308,6 +348,7 @@ public function setcompressthreshold($tresh, $savings=0.2)
case 'Memcache': case 'Memcache':
$setcompressthreshold_status = $this->m->setCompressThreshold($tresh, $savings=0.2); $setcompressthreshold_status = $this->m->setCompressThreshold($tresh, $savings=0.2);
break; break;

default: default:
$setcompressthreshold_status = TRUE; $setcompressthreshold_status = TRUE;
break; break;
Expand Down

0 comments on commit 9dde1c0

Please sign in to comment.