本文整理匯總了PHP中Illuminate\Support\Facades\Cache::driver方法的典型用法代碼示例。如果您正苦於以下問題:PHP Cache::driver方法的具體用法?PHP Cache::driver怎麽用?PHP Cache::driver使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Support\Facades\Cache
的用法示例。
在下文中一共展示了Cache::driver方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getFromCache
protected function getFromCache($key, $time, $fn)
{
$cache = Cache::driver(Cache::getDefaultDriver());
if ($cache instanceof TaggableStore) {
$cache->tags('shortener');
}
return $cache->remember($key, $time, $fn);
}
示例2: getCache
/**
* Get the cache object with tags assigned, if applicable.
*
* @return \Illuminate\Cache\CacheManager
*/
protected function getCache()
{
$cache = Cache::driver($this->cacheDriver);
return $this->cacheTags ? $cache->tags($this->cacheTags) : $cache;
}
示例3: register
/**
* Register the application services.
*
* @return void
*/
public function register()
{
$app = $this->app;
$app->bind('App\\Repositories\\User\\UserRepository', function () {
$user = new EloquentUserRepository(new User());
$cacheService = Cache::driver();
$cache = new UserCache($cacheService, $user);
$validator = App::make('validator');
return new UserValidator($validator, $cache);
});
$app->bind('App\\Repositories\\Post\\PostRepository', function () {
$post = new EloquentPostRepository(new Post());
$cacheService = Cache::driver();
$cache = new PostCache($cacheService, $post);
$validator = App::make('validator');
return new PostValidator($validator, $cache);
});
$app->bind('App\\Repositories\\News\\NewsRepository', function () {
$news = new EloquentNewsRepository(new News());
$cacheService = Cache::driver();
$cache = new NewsCache($cacheService, $news);
$validator = App::make('validator');
return new NewsValidator($validator, $cache);
});
$app->bind('App\\Repositories\\Comment\\CommentRepository', function () {
$comment = new EloquentCommentRepository(new Comment());
$cacheService = Cache::driver();
$cache = new CommentCache($cacheService, $comment);
$validator = App::make('validator');
return new CommentValidator($validator, $cache);
});
$app->bind('App\\Repositories\\QuestionType\\QuestionTypeRepository', function () {
$questionType = new EloquentQuestionTypeRepository(new QuestionType());
$cacheService = Cache::driver();
$cache = new QuestionTypeCache($cacheService, $questionType);
$validator = App::make('validator');
return new QuestionTypeValidator($validator, $cache);
});
$app->bind('App\\Repositories\\Question\\QuestionRepository', function () {
$question = new EloquentQuestionRepository(new Question());
$cacheService = Cache::driver();
$cache = new QuestionCache($cacheService, $question);
$validator = App::make('validator');
return new QuestionValidator($validator, $cache);
});
$app->bind('App\\Repositories\\QuestionAnswer\\QuestionAnswerRepository', function () {
$questionAnswer = new EloquentQuestionAnswerRepository(new Question(), new QuestionAnswer());
$cacheService = Cache::driver();
$cache = new QuestionAnswerCache($cacheService, $questionAnswer);
$validator = App::make('validator');
return new QuestionAnswerValidator($validator, $cache);
});
}