(Yaf >=1.0.0)
Yaf_Registry::get — 从注册表中检索条目
name注册表条目的名称。
以 name 存储的值;如果不存在该名称的条目,则返回 null。
示例 #1 Yaf_Registry::get() 示例
<?php
class IndexController extends Yaf_Controller_Abstract
{
public function indexAction()
{
$redis = Yaf_Registry::get("redis");
if ($redis === null) {
throw new Exception("the redis connection is not registered");
}
$this->getView()->assign("visits", $redis->get("site:visits"));
return true;
}
}
?>