MemcacheEx - Memcache extension to support setMulti and getMulti methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MemcacheEx extends Memcache | |
{ | |
public function getMulti($keys) | |
{ | |
$results = array(); | |
if ($keys) { | |
foreach ($keys as $key) { | |
$cache = parent::get($key); | |
if ($cache !== false) { | |
$results[$key] = $cache; | |
} | |
} | |
} | |
return $results; | |
} | |
public function setMulti($vars, $expire = 0, $flag = MEMCACHE_COMPRESSED) | |
{ | |
foreach ($vars as $key => $value) { | |
parent::set($key, $value, $flag, $expire); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
All credits for: http://t.co/9oVouzG
getMulti($keys); $memcache->getMulti($vars);