Skip to content

Instantly share code, notes, and snippets.

@inakiabt
Created February 16, 2011 20:12
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save inakiabt/830082 to your computer and use it in GitHub Desktop.
MemcacheEx - Memcache extension to support setMulti and getMulti methods
<?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);
}
}
}
@inakiabt
Copy link
Author

All credits for: http://t.co/9oVouzG

getMulti($keys); $memcache->getMulti($vars);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment