本文整理汇总了PHP中Memcached_DataObject::getcached方法的典型用法代码示例。如果您正苦于以下问题:PHP Memcached_DataObject::getcached方法的具体用法?PHP Memcached_DataObject::getcached怎么用?PHP Memcached_DataObject::getcached使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Memcached_DataObject
的用法示例。
在下文中一共展示了Memcached_DataObject::getcached方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Exception
/**
* Wrapper for DB_DataObject's static lookup using memcached
* as backing instead of an in-process cache array.
*
* @param string $cls classname of object type to load
* @param mixed $k key field name, or value for primary key
* @param mixed $v key field value, or leave out for primary key lookup
* @return mixed Memcached_DataObject subtype or false
*/
function &staticGet($cls, $k, $v = null)
{
if (is_null($v)) {
$v = $k;
$keys = self::pkeyCols($cls);
if (count($keys) > 1) {
// FIXME: maybe call pkeyGet() ourselves?
throw new Exception('Use pkeyGet() for compound primary keys');
}
$k = $keys[0];
}
$i = Memcached_DataObject::getcached($cls, $k, $v);
if ($i === false) {
// false == cache miss
$i = DB_DataObject::factory($cls);
if (empty($i)) {
$i = false;
return $i;
}
$result = $i->get($k, $v);
if ($result) {
// Hit!
$i->encache();
} else {
// save the fact that no such row exists
$c = self::memcache();
if (!empty($c)) {
$ck = self::cachekey($cls, $k, $v);
$c->set($ck, null);
}
$i = false;
}
}
return $i;
}
示例2: unset
/**
* Wrapper for DB_DataObject's static lookup using memcached
* as backing instead of an in-process cache array.
*
* @param string $cls classname of object type to load
* @param mixed $k key field name, or value for primary key
* @param mixed $v key field value, or leave out for primary key lookup
* @return mixed Memcached_DataObject subtype or false
*/
function &staticGet($cls, $k, $v = null)
{
if (is_null($v)) {
$v = $k;
# XXX: HACK!
$i = new $cls();
$keys = $i->keys();
$k = $keys[0];
unset($i);
}
$i = Memcached_DataObject::getcached($cls, $k, $v);
if ($i === false) {
// false == cache miss
$i = DB_DataObject::factory($cls);
if (empty($i)) {
$i = false;
return $i;
}
$result = $i->get($k, $v);
if ($result) {
// Hit!
$i->encache();
} else {
// save the fact that no such row exists
$c = self::memcache();
if (!empty($c)) {
$ck = self::cachekey($cls, $k, $v);
$c->set($ck, null);
}
$i = false;
}
}
return $i;
}
示例3: unset
function &staticGet($cls, $k, $v = null)
{
if (is_null($v)) {
$v = $k;
# XXX: HACK!
$i = new $cls();
$keys = $i->keys();
$k = $keys[0];
unset($i);
}
$i = Memcached_DataObject::getcached($cls, $k, $v);
if ($i) {
return $i;
} else {
$i = DB_DataObject::staticGet($cls, $k, $v);
if ($i) {
$i->encache();
}
return $i;
}
}