Example #1
0
 protected function getFromCache($key, $time, $fn)
 {
     $cache = Cache::driver(Cache::getDefaultDriver());
     if ($cache instanceof TaggableStore) {
         $cache->tags('shortener');
     }
     return $cache->remember($key, $time, $fn);
 }
Example #2
0
 /**
  * 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;
 }
 /**
  * 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);
     });
 }