本文整理匯總了PHP中RedBeanPHP\R::useWriterCache方法的典型用法代碼示例。如果您正苦於以下問題:PHP R::useWriterCache方法的具體用法?PHP R::useWriterCache怎麽用?PHP R::useWriterCache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類RedBeanPHP\R
的用法示例。
在下文中一共展示了R::useWriterCache方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setDb
/**
* @param $name
* @return mixed
*/
public function setDb($name)
{
$this->options = $this->db[$name];
R::setAutoResolve(TRUE);
R::selectDatabase($name);
R::ext('xdispense', function ($type) {
return R::getRedBean()->dispense($type);
});
if ($this->cache) {
R::useWriterCache(true);
R::freeze(TRUE);
}
return $name;
}
示例2: Connect
$logger = $c->get('logger');
$session = $c->get('session');
$settings = $c->get('settings')['facebook'];
$connect = new Connect($settings, $session, $logger);
return $connect;
};
$container['database'] = function ($c) {
$logger = $c->get('logger');
$settings = $c->get('settings')['database'];
define('QUESTION', 'quiz_question');
define('ANSWER', 'quiz_answer');
define('QUIZ', 'quiz_quiz');
define('USER', 'quiz_user');
// Create an extension to by-pass security check in R::dispense
R::ext('xdispense', function ($type) {
return R::getRedBean()->dispense($type);
});
R::renameAssociation(['quiz_answer_quiz_question' => 'quiz_answer_question', 'quiz_answer_quiz_quiz' => 'quiz_answer_quiz', 'quiz_question_quiz_quiz' => 'quiz_question_quiz']);
define('REDBEAN_MODEL_PREFIX', '\\App\\Model\\');
$connectionString = 'mysql:host=' . $settings['host'] . ';dbname=' . $settings['dbname'];
R::setup($connectionString, $settings['username'], $settings['password']);
R::useWriterCache(true);
//R::debug(true);
// // NEVER REMOVE THIS!
R::freeze(true);
return R::getRedBean();
};
$container['quiz'] = function ($c) {
$database = $c->get('database');
return new QuizService();
};