本文整理汇总了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);
});
}