diff --git a/app/Caches/CourseCategoryList.php b/app/Caches/CourseCategoryList.php deleted file mode 100644 index 12681a06..00000000 --- a/app/Caches/CourseCategoryList.php +++ /dev/null @@ -1,59 +0,0 @@ -lifetime; - } - - public function getKey($id = null) - { - return "course_category_list:{$id}"; - } - - public function getContent($id = null) - { - $courseRepo = new CourseRepo(); - - $categories = $courseRepo->findCategories($id); - - if ($categories->count() == 0) { - return []; - } - - return $this->handleContent($categories); - } - - /** - * @param CategoryModel[] $categories - * @return array - */ - public function handleContent($categories) - { - $result = []; - - foreach ($categories as $category) { - $result[] = [ - 'id' => $category->id, - 'name' => $category->name, - ]; - } - - return $result; - } - -} diff --git a/app/Caches/CourseTeacherList.php b/app/Caches/CourseTeacherList.php deleted file mode 100644 index 1c676f1a..00000000 --- a/app/Caches/CourseTeacherList.php +++ /dev/null @@ -1,63 +0,0 @@ -lifetime; - } - - public function getKey($id = null) - { - return "course_teacher_list:{$id}"; - } - - public function getContent($id = null) - { - $courseRepo = new CourseRepo(); - - $users = $courseRepo->findTeachers($id); - - if ($users->count() == 0) { - return []; - } - - return $this->handleContent($users); - } - - /** - * @param UserModel[] $users - * @return array - */ - public function handleContent($users) - { - $result = []; - - foreach ($users as $user) { - $result[] = [ - 'id' => $user->id, - 'name' => $user->name, - 'avatar' => $user->avatar, - 'vip' => $user->vip, - 'title' => $user->title, - 'about' => $user->about, - ]; - } - - return $result; - } - -} diff --git a/app/Caches/FeaturedArticleList.php b/app/Caches/FeaturedArticleList.php index 86507ebe..7f1d7640 100644 --- a/app/Caches/FeaturedArticleList.php +++ b/app/Caches/FeaturedArticleList.php @@ -16,6 +16,8 @@ class FeaturedArticleList extends Cache protected $lifetime = 3600; + protected $limit = 5; + public function getLifetime() { return $this->lifetime; @@ -28,9 +30,7 @@ class FeaturedArticleList extends Cache public function getContent($id = null) { - $limit = 8; - - $articles = $this->findArticles($limit); + $articles = $this->findArticles($this->limit); if ($articles->count() == 0) { return []; @@ -67,7 +67,7 @@ class FeaturedArticleList extends Cache * @param int $limit * @return ResultsetInterface|Resultset|ArticleModel[] */ - protected function findArticles($limit = 8) + protected function findArticles($limit = 5) { return ArticleModel::query() ->where('featured = 1') diff --git a/app/Caches/FeaturedCourseList.php b/app/Caches/FeaturedCourseList.php index c5c05c58..d9b26459 100644 --- a/app/Caches/FeaturedCourseList.php +++ b/app/Caches/FeaturedCourseList.php @@ -16,6 +16,8 @@ class FeaturedCourseList extends Cache protected $lifetime = 3600; + protected $limit = 5; + public function getLifetime() { return $this->lifetime; @@ -28,9 +30,7 @@ class FeaturedCourseList extends Cache public function getContent($id = null) { - $limit = 5; - - $courses = $this->findCourses($limit); + $courses = $this->findCourses($this->limit); if ($courses->count() == 0) { return []; diff --git a/app/Caches/FeaturedQuestionList.php b/app/Caches/FeaturedQuestionList.php index 9a64b958..07ee392c 100644 --- a/app/Caches/FeaturedQuestionList.php +++ b/app/Caches/FeaturedQuestionList.php @@ -16,6 +16,8 @@ class FeaturedQuestionList extends Cache protected $lifetime = 3600; + protected $limit = 5; + public function getLifetime() { return $this->lifetime; @@ -28,9 +30,7 @@ class FeaturedQuestionList extends Cache public function getContent($id = null) { - $limit = 5; - - $questions = $this->findQuestions($limit); + $questions = $this->findQuestions($this->limit); if ($questions->count() == 0) { return []; diff --git a/app/Caches/HelpList.php b/app/Caches/HelpList.php index 2899bbd8..5c30bea4 100644 --- a/app/Caches/HelpList.php +++ b/app/Caches/HelpList.php @@ -15,7 +15,7 @@ use Phalcon\Mvc\Model\ResultsetInterface; class HelpList extends Cache { - protected $lifetime = 365 * 86400; + protected $lifetime = 7 * 86400; public function getLifetime() { diff --git a/app/Caches/HotQuestionList.php b/app/Caches/HotQuestionList.php index 64220fd8..3afbec0b 100644 --- a/app/Caches/HotQuestionList.php +++ b/app/Caches/HotQuestionList.php @@ -14,13 +14,11 @@ use Phalcon\Mvc\Model\ResultsetInterface; class HotQuestionList extends Cache { - protected $lifetime = 86400; + protected $lifetime = 3600; public function getLifetime() { - $tomorrow = strtotime('tomorrow'); - - return $tomorrow - time(); + return $this->lifetime; } public function getKey($id = null) diff --git a/app/Caches/IndexArticleList.php b/app/Caches/IndexArticleList.php index c892923f..43075b7c 100644 --- a/app/Caches/IndexArticleList.php +++ b/app/Caches/IndexArticleList.php @@ -14,7 +14,7 @@ use App\Services\Logic\Article\ArticleList as ArticleListService; class IndexArticleList extends Cache { - protected $lifetime = 15 * 60; + protected $lifetime = 3600; public function getLifetime() { diff --git a/app/Caches/IndexFeaturedCourseList.php b/app/Caches/IndexFeaturedCourseList.php index f7d0e6ae..77bb347b 100644 --- a/app/Caches/IndexFeaturedCourseList.php +++ b/app/Caches/IndexFeaturedCourseList.php @@ -19,7 +19,7 @@ use Phalcon\Mvc\Model\ResultsetInterface; class IndexFeaturedCourseList extends Cache { - protected $lifetime = 86400; + protected $lifetime = 3600; public function getLifetime() { diff --git a/app/Caches/IndexFreeCourseList.php b/app/Caches/IndexFreeCourseList.php index bc20a9dc..9ae4226c 100644 --- a/app/Caches/IndexFreeCourseList.php +++ b/app/Caches/IndexFreeCourseList.php @@ -19,7 +19,7 @@ use Phalcon\Mvc\Model\ResultsetInterface; class IndexFreeCourseList extends Cache { - protected $lifetime = 86400; + protected $lifetime = 3600; public function getLifetime() { diff --git a/app/Caches/IndexLiveList.php b/app/Caches/IndexLiveList.php index 734150a1..ae3dff4e 100644 --- a/app/Caches/IndexLiveList.php +++ b/app/Caches/IndexLiveList.php @@ -18,7 +18,7 @@ use Phalcon\Mvc\Model\ResultsetInterface; class IndexLiveList extends Cache { - protected $lifetime = 86400; + protected $lifetime = 3600; public function getLifetime() { diff --git a/app/Caches/IndexNewCourseList.php b/app/Caches/IndexNewCourseList.php index 4975cb27..457eb8ce 100644 --- a/app/Caches/IndexNewCourseList.php +++ b/app/Caches/IndexNewCourseList.php @@ -19,7 +19,7 @@ use Phalcon\Mvc\Model\ResultsetInterface; class IndexNewCourseList extends Cache { - protected $lifetime = 86400; + protected $lifetime = 3600; public function getLifetime() { diff --git a/app/Caches/IndexQuestionList.php b/app/Caches/IndexQuestionList.php index b79db98b..12bb02c1 100644 --- a/app/Caches/IndexQuestionList.php +++ b/app/Caches/IndexQuestionList.php @@ -14,7 +14,7 @@ use App\Services\Logic\Question\QuestionList as QuestionListService; class IndexQuestionList extends Cache { - protected $lifetime = 15 * 60; + protected $lifetime = 3600; public function getLifetime() { diff --git a/app/Caches/IndexSimpleFeaturedCourseList.php b/app/Caches/IndexSimpleFeaturedCourseList.php index b5433216..616a37bd 100644 --- a/app/Caches/IndexSimpleFeaturedCourseList.php +++ b/app/Caches/IndexSimpleFeaturedCourseList.php @@ -17,7 +17,7 @@ use Phalcon\Mvc\Model\ResultsetInterface; class IndexSimpleFeaturedCourseList extends Cache { - protected $lifetime = 86400; + protected $lifetime = 3600; public function getLifetime() { diff --git a/app/Caches/IndexSimpleFreeCourseList.php b/app/Caches/IndexSimpleFreeCourseList.php index 34a6d4f7..16b0e64f 100644 --- a/app/Caches/IndexSimpleFreeCourseList.php +++ b/app/Caches/IndexSimpleFreeCourseList.php @@ -17,7 +17,7 @@ use Phalcon\Mvc\Model\ResultsetInterface; class IndexSimpleFreeCourseList extends Cache { - protected $lifetime = 86400; + protected $lifetime = 3600; public function getLifetime() { diff --git a/app/Caches/IndexSimpleNewCourseList.php b/app/Caches/IndexSimpleNewCourseList.php index 7dffa5af..9dbd225c 100644 --- a/app/Caches/IndexSimpleNewCourseList.php +++ b/app/Caches/IndexSimpleNewCourseList.php @@ -17,7 +17,7 @@ use Phalcon\Mvc\Model\ResultsetInterface; class IndexSimpleNewCourseList extends Cache { - protected $lifetime = 86400; + protected $lifetime = 3600; public function getLifetime() { diff --git a/app/Caches/IndexSimpleVipCourseList.php b/app/Caches/IndexSimpleVipCourseList.php index 6756b39e..90f8b493 100644 --- a/app/Caches/IndexSimpleVipCourseList.php +++ b/app/Caches/IndexSimpleVipCourseList.php @@ -17,7 +17,7 @@ use Phalcon\Mvc\Model\ResultsetInterface; class IndexSimpleVipCourseList extends Cache { - protected $lifetime = 86400; + protected $lifetime = 3600; public function getLifetime() { diff --git a/app/Caches/IndexSlideList.php b/app/Caches/IndexSlideList.php index abc7d28c..00f15ae1 100644 --- a/app/Caches/IndexSlideList.php +++ b/app/Caches/IndexSlideList.php @@ -14,7 +14,7 @@ use Phalcon\Mvc\Model\ResultsetInterface; class IndexSlideList extends Cache { - protected $lifetime = 365 * 86400; + protected $lifetime = 3600; public function getLifetime() { diff --git a/app/Caches/IndexVipCourseList.php b/app/Caches/IndexVipCourseList.php index 6b268160..e11ce1b2 100644 --- a/app/Caches/IndexVipCourseList.php +++ b/app/Caches/IndexVipCourseList.php @@ -19,7 +19,7 @@ use Phalcon\Mvc\Model\ResultsetInterface; class IndexVipCourseList extends Cache { - protected $lifetime = 86400; + protected $lifetime = 3600; public function getLifetime() { diff --git a/app/Caches/TaggedArticleList.php b/app/Caches/TaggedArticleList.php index d57faf7b..1c5c6df0 100644 --- a/app/Caches/TaggedArticleList.php +++ b/app/Caches/TaggedArticleList.php @@ -15,7 +15,7 @@ class TaggedArticleList extends Cache protected $limit = 5; - protected $lifetime = 86400; + protected $lifetime = 3600; public function getLifetime() { diff --git a/app/Caches/TaggedQuestionList.php b/app/Caches/TaggedQuestionList.php index 7495823b..f76a5b29 100644 --- a/app/Caches/TaggedQuestionList.php +++ b/app/Caches/TaggedQuestionList.php @@ -15,7 +15,7 @@ class TaggedQuestionList extends Cache protected $limit = 5; - protected $lifetime = 86400; + protected $lifetime = 3600; public function getLifetime() { diff --git a/app/Caches/TopAnswererList.php b/app/Caches/TopAnswererList.php index 37991604..4acaa8e7 100644 --- a/app/Caches/TopAnswererList.php +++ b/app/Caches/TopAnswererList.php @@ -16,7 +16,7 @@ use Phalcon\Mvc\Model\ResultsetInterface; class TopAnswererList extends Cache { - protected $lifetime = 86400; + protected $lifetime = 3600; public function getLifetime() { diff --git a/app/Caches/TopAuthorList.php b/app/Caches/TopAuthorList.php index 882e4cab..1e6a2404 100644 --- a/app/Caches/TopAuthorList.php +++ b/app/Caches/TopAuthorList.php @@ -16,7 +16,7 @@ use Phalcon\Mvc\Model\ResultsetInterface; class TopAuthorList extends Cache { - protected $lifetime = 86400; + protected $lifetime = 3600; public function getLifetime() { diff --git a/app/Services/Logic/Course/TeacherList.php b/app/Services/Logic/Course/TeacherList.php deleted file mode 100644 index c40e5d48..00000000 --- a/app/Services/Logic/Course/TeacherList.php +++ /dev/null @@ -1,30 +0,0 @@ -checkCourse($id); - - $cache = new CourseTeacherListCache(); - - $result = $cache->get($course->id); - - return $result ?: []; - } - -}