AdviserIndustryCategoryDao { const CACHE_TIME = 360; private $cacheRepository; public function __construct(Repository $cacheRepository) { $this->cacheRepository = $cacheRepository; } public function getList(int $userId) { $key = $this->getKey($userId); if ($this->cacheRepository->has($key)) { return $this->cacheRepository->get($key); } $result = parent::getList($userId); $this->cacheRepository->add($key, $result, self::CACHE_TIME); return $result; } public function create(int $userId, int $industryCategory) { $this->cacheRepository->forget($this->getKey($userId)); return parent::create($userId, $industryCategory); } private function getKey(int $userId): string { return __CLASS__ . "getList" . $userId; } }