Don't spew warnings on usage of MEMCACHE_COMPRESSED constant when memcache PHP extension is not present.
Switched to a locally-defined Cache::COMPRESSED, translating that to MEMCACHE_COMPRESSED in the plugin.
This commit is contained in:
parent
8d320d7cc2
commit
875e1a70ce
@ -363,7 +363,7 @@ class Memcached_DataObject extends DB_DataObject
|
|||||||
$cached[] = clone($inst);
|
$cached[] = clone($inst);
|
||||||
}
|
}
|
||||||
$inst->free();
|
$inst->free();
|
||||||
$c->set($ckey, $cached, MEMCACHE_COMPRESSED, $expiry);
|
$c->set($ckey, $cached, Cache::COMPRESSED, $expiry);
|
||||||
return new ArrayWrapper($cached);
|
return new ArrayWrapper($cached);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +47,8 @@ class Cache
|
|||||||
var $_items = array();
|
var $_items = array();
|
||||||
static $_inst = null;
|
static $_inst = null;
|
||||||
|
|
||||||
|
const COMPRESSED = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Singleton constructor
|
* Singleton constructor
|
||||||
*
|
*
|
||||||
@ -133,7 +135,7 @@ class Cache
|
|||||||
*
|
*
|
||||||
* @param string $key The key to use for lookups
|
* @param string $key The key to use for lookups
|
||||||
* @param string $value The value to store
|
* @param string $value The value to store
|
||||||
* @param integer $flag Flags to use, mostly ignored
|
* @param integer $flag Flags to use, may include Cache::COMPRESSED
|
||||||
* @param integer $expiry Expiry value, mostly ignored
|
* @param integer $expiry Expiry value, mostly ignored
|
||||||
*
|
*
|
||||||
* @return boolean success flag
|
* @return boolean success flag
|
||||||
|
@ -102,7 +102,7 @@ class MemcachePlugin extends Plugin
|
|||||||
*
|
*
|
||||||
* @param string &$key in; Key to use for lookups
|
* @param string &$key in; Key to use for lookups
|
||||||
* @param mixed &$value in; Value to associate
|
* @param mixed &$value in; Value to associate
|
||||||
* @param integer &$flag in; Flag (passed through to Memcache)
|
* @param integer &$flag in; Flag empty or Cache::COMPRESSED
|
||||||
* @param integer &$expiry in; Expiry (passed through to Memcache)
|
* @param integer &$expiry in; Expiry (passed through to Memcache)
|
||||||
* @param boolean &$success out; Whether the set was successful
|
* @param boolean &$success out; Whether the set was successful
|
||||||
*
|
*
|
||||||
@ -115,7 +115,7 @@ class MemcachePlugin extends Plugin
|
|||||||
if ($expiry === null) {
|
if ($expiry === null) {
|
||||||
$expiry = $this->defaultExpiry;
|
$expiry = $this->defaultExpiry;
|
||||||
}
|
}
|
||||||
$success = $this->_conn->set($key, $value, $flag, $expiry);
|
$success = $this->_conn->set($key, $value, $this->flag(intval($flag)), $expiry);
|
||||||
Event::handle('EndCacheSet', array($key, $value, $flag,
|
Event::handle('EndCacheSet', array($key, $value, $flag,
|
||||||
$expiry));
|
$expiry));
|
||||||
return false;
|
return false;
|
||||||
@ -197,6 +197,20 @@ class MemcachePlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Translate general flags to Memcached-specific flags
|
||||||
|
* @param int $flag
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
protected function flag($flag)
|
||||||
|
{
|
||||||
|
$out = 0;
|
||||||
|
if ($flag & Cache::COMPRESSED == Cache::COMPRESSED) {
|
||||||
|
$out |= MEMCACHE_COMPRESSED;
|
||||||
|
}
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
function onPluginVersion(&$versions)
|
function onPluginVersion(&$versions)
|
||||||
{
|
{
|
||||||
$versions[] = array('name' => 'Memcache',
|
$versions[] = array('name' => 'Memcache',
|
||||||
|
Loading…
Reference in New Issue
Block a user