Upgrade to Pro — share decks privately, control downloads, hide ads and more …

自分のLaravel アプリケーション設計晒す

自分のLaravel アプリケーション設計晒す

Kazuhei Arai

July 12, 2017
Tweet

More Decks by Kazuhei Arai

Other Decks in Programming

Transcript

  1. !LB[VIFJ ๻ͱ-BSBWFM w ৽͍͠ձࣾʹೖࣾͯ͠৽ن։ൃϓϩδΣΫτΛ೚͞Εͨ ࠓ೥ͷ݄̍  w ΤϯδχΞ͸ࣗ෼ͻͱΓ σβΠϯ)5.-4$44͸֎෦ 

    w ։ൃظؒ͸໿ϲ݄ w 1)1ͷܦݧ͕Ұ൪ଟ͔ͬͨͷͰ1)1Ͱ࡞Δ͜ͱʹ w ϑϨʔϜϫʔΫΛௐ΂ͨͱ͜Ζ-BSBWFM͕ྑ͛ͩͬͨ͞ Ҏલͷձࣾ͸ ಠࣗ.7$ϑϨʔϜϫʔΫͩͬͨ
  2. !LB[VIFJ ϨΠϠʔ෼͚ ϦΫΤετ ίϯτϩʔϥʔ ΞϓϦέʔγϣϯ αʔϏε υϝΠϯ αʔϏε ϦϙδτϦʔ %BP

    ΞϓϦέʔγϣϯ υϝΠϯ Πϯϑϥ 3FRVFTUܕ υϝΠϯͷܕ QSJNJUJWFͳܕ QSJNJUJWFͳܕ
  3. !LB[VIFJ ϨΠϠʔ෼͚ ίϯτϩʔϥʔ ΞϓϦέʔγϣϯ αʔϏε υϝΠϯ αʔϏε ΤϯςΟςΟ ϦϙδτϦʔ %BP

    ίϯόʔλʔ Ϗϡʔ ΞϓϦέʔγϣϯ υϝΠϯ Πϯϑϥ TUE$MBTT υϝΠϯͷܕ 2VFSZ#VJMEFSར༻
  4. !LB[VIFJ Ϋϥε෼͚ 6TFS$POUSPMMFSVQEBUF 6TFS6QEBUF3FRVFTUSFRVFTU 3FHJTUFS4FSWJDFVQEBUF SFRVFTU ΞϓϦέʔγϣϯ υϝΠϯ Πϯϑϥ %PNBJOa6TFSa3FHJTUFS4FSWJDFSFHJTUFS

    6TFS*EVTFS*E BSSBZQBSBN %PNBJOa6TFSa6TFS3FQPTJUPSZ*OUFSGBDFVQEBUF 6TFS*EVTFS*E BSSBZQBSBN 6TFS %PNBJOa6TFSa6TFS3FQPTJUPSZVQEBUF 6TFS*EVTFS*E BSSBZQBSBN 6TFS *OGSBa6TFSa6TFS%BPVQEBUF JOUVTFS*E BSSBZEBUB TUE$MBTT %PNBJOa6TFSa6TFS$POWFSUFSUP&OUJUZ aTUE$MBTTVTFS 6TFS ࣮૷ %PNBJOa6TFSa6TFS
  5. !LB[VIFJ Ωϟογϡ 6TFS$POUSPMMFSVQEBUF 6TFS6QEBUF3FRVFTUSFRVFTU 3FHJTUFS4FSWJDFVQEBUF SFRVFTU ΞϓϦέʔγϣϯ υϝΠϯ Πϯϑϥ %PNBJOa6TFSa3FHJTUFS4FSWJDFSFHJTUFS

    6TFS*EVTFS*E BSSBZQBSBN %PNBJOa6TFSa6TFS3FQPTJUPSZ*OUFSGBDFVQEBUF 6TFS*EVTFS*E BSSBZQBSBN 6TFS %PNBJOa6TFSa6TFS3FQPTJUPSZVQEBUF 6TFS*EVTFS*E BSSBZQBSBN 6TFS *OGSBa6TFSa$BDIF6TFS%BPVQEBUF JOUVTFS*E BSSBZEBUB TUE$MBTT %PNBJOa6TFSa6TFS$POWFSUFSUP&OUJUZ aTUE$MBTTVTFS 6TFS ࣮૷ %PNBJOa6TFSa6TFS
  6. !LB[VIFJ Ωϟογϡ <?php namespace Infra\Database\Dao\Adviser; use Illuminate\Cache\Repository; class CachedAdviserIndustryCategoryDao extends

    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; } }
  7. !LB[VIFJ ࡶײ w $POUSPMMFS͔Β3FQPTJUPSZΛ௚઀ݺͼग़͍ͯ͠ΔՕॴͷϧʔϧͮ͘ΓΛ͍ͨ͠ w ࣗ෼Ͱ%BPͱ$POWFSUFSॻܾ͘ҙ͕ૣ͗ͨ͢ɻ&MPRVFOUΛ΋͏ͪΐͬͱݕ౼͠ ͯ΋ྑ͔ͬͨɻςʔϒϧΛΦϒδΣΫτʹϚοϐϯά͢Δͷ͕ਏ͍ w ࠓ͸ඞཁͳ͍͕ΞΫηε͕૿͑ͨΒ3FQPTJUPSZΛTJOHMFUPOʹͯ͠΋͏Ұ૚ DBDIF͢Δͱྑͦ͞͏

    w υϝΠϯ૚Ͱ΋݁ߏϓϦϛςΟϒͳܕΛ࢖͍ͬͯΔͷͰɺ΋ͬͱͪΌΜͱܕͰ දݱ͍ͨ͠ɻͰ΋େมͦ͏ͩ͠ใΘΕͳͦ͞͏ w ΤϯςΟςΟͷ*%ͷൃ൪Λ%#ͷBVUPJODSFNFOUͰߦ͍ͬͯΔͷͰɺҰ౓%#ʹ อଘ͠ͳ͍ͱ׬શͳΤϯςΟςΟ͕࡞Εͳ͍ w +PCͱ/PUJpDBUJPOͱ.BJMͷΫϥεͷ࢖͍෼͚͕෼͔ͬͯͳͯ͘ແବʹΫϥεॻ ͍ͯΔؾ͕͢Δ