本文整理汇总了PHP中Service::getModelCache方法的典型用法代码示例。如果您正苦于以下问题:PHP Service::getModelCache方法的具体用法?PHP Service::getModelCache怎么用?PHP Service::getModelCache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Service
的用法示例。
在下文中一共展示了Service::getModelCache方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: storeInCache
/**
* Store the model in the cache
*
* @return self
*/
protected function storeInCache()
{
if (!Service::getModelCache()) {
return $this;
}
Service::getModelCache()->save($this);
return $this;
}
示例2: retrieveFromCache
/**
* Load the current object's properties from the cache
* @return bool True if the assignement was successful, false if the model
* doesn't exist in the cache
*/
protected function retrieveFromCache()
{
if (!$this->existsInCache()) {
return false;
}
$cachedModel = Service::getModelCache()->get(get_class($this), $this->id);
$this->copy($cachedModel);
return true;
}
示例3: collect
/**
* Collects data for the given Request and Response, so that it can be
* serialized and stored for later retrieval
*
* @param Request $request A Request instance
* @param Response $response A Response instance
* @param \Exception $exception An Exception instance
*/
public function collect(Request $request, Response $response, \Exception $exception = null)
{
$this->data = array('queries' => $this->queries, 'cachedModels' => \Service::getModelCache()->all(), 'cacheFetches' => $this->cacheFetches);
}
示例4: clearDatabase
/**
* @Given that the database is empty
*/
public static function clearDatabase()
{
$db = Database::getInstance();
// Get an array of the tables in the database, so that we can remove them
$tables = array_map(function ($val) {
return current($val);
}, $db->query('SHOW TABLES'));
if (count($tables) > 0) {
$db->execute('SET foreign_key_checks = 0');
$db->execute('DROP TABLES ' . implode($tables, ','));
$db->execute('SET foreign_key_checks = 1');
}
ScriptHandler::migrateDatabase(null, true);
if ($modelCache = Service::getModelCache()) {
$modelCache->clear();
}
}