ãã㯠ã¯ã¦ãªã¨ã³ã¸ã㢠Advent Calendar 2023 ã® 18 æ¥ç®ã®è¨äºã§ããæ¨æ¥ã¯ id:gurrium ã«ãã private-isuã§70ä¸ç¹åãããã«ãã£ãã㨠- ãã®ã ã§ãããç§ã¯ 50 ä¸ç¹ãããã§æºè¶³ãã¦ãã¾ã£ã¦ããã®ã§ããã£ããè©°ãã¦ãã¦åããªã¨æãã
developer.hatenastaff.com
Web ã¢ããªã±ã¼ã·ã§ã³éçºã«ããã¦ãããã£ãã·ã¥ã¯éº»è¬ãã¨ããè¨èãã¤ã³ã¿ã¼ãããä¸ãããé£ã³äº¤ã£ã¦ãã¾ããYAPC::Kansai OSAKA 2017 ã® id:moznion ã®ãã¼ã¯ã§ããç¥ãããããã«ãªã£ãã¯ã¼ããããªãããªã
ååºã¯ã¡ããã¨ã¯åãããªããã§ãããå°ãªãã¨ã 2011 å¹´ã«ã¯è¨ããã¦ãã¾ããã
ãã£ãã·ã¥ã«é ¼ãã¨å³æçã«ããã©ã¼ãã³ã¹ã解決ããããã®å³æå¹æã«é
äºããã¦ãã¾ããæ ¹æ¬çãªããã©ã¼ãã³ã¹åé¡ãè¦ãé ããã¾ã¾ãã£ãã·ã¥ã«ä¾åããããã«ãªããããã¦è±åºããã®ãé£ãããã¨ããæ§è³ªããã表ãã¦ããè¨èã§ããã§ãããæ¬å½ã«ãã£ãã·ã¥ã«ä¾åããã®ã¯ééã£ã¦ãããã§ããããã
ããã£ãã·ã¥ã¯éº»è¬ãã¨ããè¨èã«ããããã£ãã·ã¥ï¼ä½¿ãã¹ãã§ã¯ãªããã¨æèåæ¢ãã¦ãã¾ãããã¾ã£ã¦ããã®ã§ã¯ãªãããåæä¸çµ¡ãã«ã麻è¬ãã¨è¨ãã®ã§ã¯ãªãããã£ãã·ã¥ããã¿ã¼ã³åãã¦ä¹ãããªãã¨ããã®ãæã¾ãã姿ã§ããããç¾ä»£ç㪠Web ã¢ããªã±ã¼ã·ã§ã³éçºã«ããã¦ããã£ãã·ã¥ã使ãã®ã¯ãããåæã¨ããªãã¨æ©è½ããªãã¨ç§ã¯èãã¾ãã
ãã¿ã¼ã³å㯠moznion ã®çºè¡¨ã§ãããã¦ãããã ãã©ãç§ã®ç®ç·ãããåé¡ãã¦ã¿ã¾ãã
HTTP Response ãã£ãã·ã¥ (æã
ã server ã®ã¨ã)
ã¬ã¹ãã³ã¹ãã¾ãã£ã¨ CDN çã§ãã£ãã·ã¥ãã¦ãã¾ããã¿ã¼ã³ãç¾ä»£ã® Web ã¢ããªã±ã¼ã·ã§ã³ã§ã¯åºæ¬çã« CDN ã¯æãåæã§ããããããããã¯ãã¡ãã許容ããã¦ãããã£ãã·ã¥ã§ãããã
ãããã¡ãªå¤±æã¨ãã¦ãèªè¨¼ãå¿
è¦ãªãã¼ã¸ããã£ãã·ã¥ãã¦ãã¾ãã¨ããã®ããããã¾ããPC ã¨ã¹ããã¨ã§åºãåããã¨ããªã©ãCDN ã®ãã£ãã·ã¥ãã¼ã¨ã¢ããªã±ã¼ã·ã§ã³ã®åºãåãæ¡ä»¶ãç°ãªã£ã¦ãã¦ãéãç°å¢åãã®ã³ã³ãã³ãããã£ãã·ã¥ãã¦ãã¾ããã¹ãæã
çºçãã¦ããã
ä¸åº¦ãã£ãã·ã¥ãã¦ãã¾ã£ããã¢ããªã±ã¼ã·ã§ã³ã®å¶å¾¡ä¸ãããæåã§è¿ãã¦ãã¾ãããããã£ãã·ã¥ã®ãã¼ã¸ãããããé£ããã
ã¹ãçãªãå¯ä½ç¨ã®ç¡ãå¦çãªããã£ãã·ã¥å¯è½ã¨ããèãæ¹ã§æ±ããã ãã©ãå¯ä½ç¨ã®ãããªã¯ã¨ã¹ãã§ã Idempotency-Key Header ãå©ç¨ãã¦é«éã«ã¬ã¹ãã³ã¹ãè¿ããã¿ã¼ã³ããããããã¯ã¯ã©ã¤ã¢ã³ãããã®ãªãã©ã¤æã«ä½¿ãã¾ãã
HTTP Response ãã£ãã·ã¥ (æã
ã client ã®ã¨ã)
ãµã¼ãã¼å´ããã£ãã®ã§ãã¯ã©ã¤ã¢ã³ãå´ãæ¸ãã¦ãããèªåãåãåã£ãã¬ã¹ãã³ã¹ãä¿åï¼ãã£ãã·ã¥ï¼ãã¦ããã®ã¯ãé度以å¤ã ã¨ä¸»ã«ä»¥ä¸ã®ç®çã§ãã
- å¤é¨ã«ãªã¯ã¨ã¹ããæãéããªãããã«
- å¤é¨ãè½ã¡ã¦ãã¦ãéç¨ã«å½±é¿ãåºãªãããã«
ãªã¯ã¨ã¹ããæããããªãããã«ããããã«ã¯ãæçµåå¾æ¥æãæã£ã¦ãæ¯è¼ããªãããªã¯ã¨ã¹ããæããã°è¯ããSquid çã® proxy ãã unique å¶éä»ãã® request queue (åã URL ã«å¯¾ãã queue 㯠1 ã¤ã«ãã¼ã¸ããçãª) ã§å¯¾å¿ãããã¨ãå¤ããã
ãªã¯ã¨ã¹ãå
ãè½ã¡ã¦ãã¦ããã£ãã·ã¥ããã©ãã«ãããã®ã¯ãSWR çãªèãæ¹ã§ããããstale ã§ãç·æ¥æã«ä½¿ã£ã¦è¯ããã£ãã·ã¥ãã¨ããã®ã¯ããã
ã«ã¦ã³ã¿ã¼ãã£ãã·ã¥
Rails Guide ã«æ¸ãã¦ããç¨åº¦ã«ã¯ä¸è¬çãªãã£ãã·ã¥ãbelongs_to
ã«ãªãã·ã§ã³ã追å ããã ãã¨ãããé常ã«æãåºããããã¢ããªã³ã°ãããã¦ããã®ã§ãããã使ã£ã¦è¯ããã£ãã·ã¥ã ããã
guides.rubyonrails.org
ä¾ãã° Entry -> Comment ã¨ããé¢é£ãããã¨ãã«ãentries
ãã¼ãã«ã« comments_count
ã«ã©ã ãæã£ã¦ãã³ã¡ã³ããä½ããã/åé¤ããããã³ã« comments_count
ã«ã©ã ãæ´æ°ããã
ãã®ããã«ãåã®è¦ç´ æ°ã親ã«æã£ã¦ãããã®ã¯é常ã«ä¸è¬çãªè¦ä»¶ã ã¨æããã ãã©ãã«ã¦ã³ã¿ã¼ãã£ãã·ã¥ä»¥å¤ã«ååä»ãã¦ãããã§ãããï¼ãã®ãã¿ã¼ã³ã®ååãä»ã«èããªããªã¨æã£ã¦ããã
ã¨ãã㧠Rails ã§ã«ã¦ã³ã¿ã¼ãã£ãã·ã¥ãå®ç¾ããã¨ãã«ãActiveRecord ã«çµã¿è¾¼ã¿ã®ãã®ã¨ãããæè»ã«æ±ãã counter_culture gem ã¨ãããã¾ããcounter_culture ã¯ã³ã¼ãèªãã®ã¨ã¦ããªã¹ã¹ã¡ã§ããREADME ã ãã§ããã«ã¦ã³ã¿ã¼ãã£ãã·ã¥ãã«ã ãã¶è²ããªè¦ä»¶ãããã®ãåãã£ã¦é¢ç½ãã¨æãã
ãã¼ã¿ãå¼ããããå½¢ã«å å·¥ãããã£ãã·ã¥
ã©ãè¨ãã°ããã®ãåãããªãã¦ãã¿ã¼ã³åãä»ãããã¦ããªããã¤ã¡ã¼ã¸ã¯ã«ã¦ã³ã¿ã¼ãã£ã·ã¥ã¨åãããã ã«ã¦ã³ã¿ã¼ãã£ãã·ã¥ãã«ã¦ã³ã¿ã¼ã«ç¹åãã¦ããã®ã¨æ¯ã¹ãå¿
è¦ãªãã¼ã¿ãå¿
è¦ãªå½¢ã«å å·¥ãã¦ä¿åãã¦ããã¨ããã®ãç¹å¾´ã
ä¾ãã° Markdown ã§æ¸ããããã°ã® HTML Body ããã®ãã¿ã¼ã³ã«å½ããããã¹ã¿ã¨ãªããã¼ã¿ãæ´æ°ããã¨ãã«ãä¸ç·ã« or éåæã§ãã£ãã·ã¥ãã¼ã¿ãçæããã
ã¢ã¯ã»ã¹æ°ã©ã³ãã³ã°ãããã§ãããã¢ã¯ã»ã¹ãã°ã¨ããã¤ãã³ããã¼ã¿ã¨ããã®å å·¥å
ã¨ãã¦ã®æ¬æ¥ã®ã¢ã¯ã»ã¹æ°ã©ã³ãã³ã°ãã©ã³ãã³ã°è¡¨ç¤ºæã«ã¢ã¯ã»ã¹ãã°ãæ¯åèãããã¯ãããäºåã«éè¨ãã¦ããããå¼ããããå½¢ã«å å·¥ãããã®ãæã£ã¦ããã¯ãã§ãã
ã¢ã¯ã»ã¹æ°ã©ã³ãã³ã°ãæ³åããã¨ãã¤ãã³ãã½ã¼ã·ã³ã°ã®èãæ¹ã¨ãè¿ããåå¨ã§ããã¨ããã®ãåããã¨æãã¾ããã¤ãã³ããå
¨ã¦ã¢ãã©ã¤ãããªã½ã¼ã¹ã¯ãä»®ã«å¤±ã£ã¦ãã¤ãã³ãããåçæã§ããã®ã§ããã£ãã·ã¥ã®ãããªãã®ã§ããã
ãã®ãã¿ã¼ã³ã®å ´åãä»è¦ã¦ãããã£ãã·ã¥ã¯ã©ãã¾ã§ãã¢ãã©ã¤ãããã®ãªã®ããåããã¥ãããªããã§ãããåæçã«æ±ãã¦ããã°ãã®æ©ã¿ã¨ã¯ç¡ç¸ã§ãããªã®ã§ãã©ã³ã¶ã¯ã·ã§ã³ãæã¤ãã¼ã¿ã¹ãã¢ã§ããã¹ã¿ãã¼ã¿ã¨ãã£ãã·ã¥ã¨ãåããã¼ã¿ã¹ãã¢ã§æ±ãã¨æ¥½ã«ãªãã¾ããããã§ãªãå ´åã¯ãé å¼µãã¾ããããï¼å®è£
ãã¿ã¼ã³ã¯å¹¾ã¤ããããã ãã©ãä½ç½ã足ããªãï¼
ãã©ã°ã¡ã³ããã£ãã·ã¥
HTML ã®ãã¼ãåä½ã§ãã£ãã·ã¥ãããããã Rails ã¬ã¤ãã«ããã¾ããã
guides.rubyonrails.org
ã¬ã³ããªã³ã°æã«ãã£ãã·ã¥ãããã°ä½¿ãããªããã°ãã£ãã·ã¥ãä½ããã¨ããåãããããå
·ä½çã«ã¯ä»¥ä¸ã®ãããªã³ã¼ãã
<% @entries.each do |entry| %>
<% cache entry do %>
<%= render entry %>
<% end %>
<% end %>
ãã㯠entry
ã render ãããã®ããentry
ã® id
㨠updated_at
ããã¼ã¨ãã¦ãã£ãã·ã¥ãã¦ãããupdated_at
ããã¼ã«å«ã¾ãã¦ããã®ã§ãæ´æ°ããã¨ãã£ãã·ã¥ãã¼ãå¤ããï¼ãã£ãã·ã¥ãã¹ã¨ãªããæ´æ°ãããæ°ããã³ã³ãã³ãã§æç»ããããï¼å®éã¯ãã£ã¨è¤éãªãã¨ããã¦ãããã©ãæ¦è¦ã¨ãã¦ã¯åã£ã¦ãã¯ãï¼
View ãã·ãªã¢ã©ã¤ã¶ã§ãã£ãã·ã¥ããã¨ããèãæ¹ãªã®ã§ãHTML ãé¢ã㦠JSON API ã¨ãªã£ã¦ãæ´»ç¨ãããã¨ã¯ã§ããã
ã¨ããã§éçºãæ´»çºãªï¼ï¼ï¼ã¢ããªã±ã¼ã·ã§ã³ã§ã®ãã©ã°ã¡ã³ããã£ãã·ã¥ã§ã¯ãã³ã³ãã³ãã®æ´æ°ã¨ãã³ãã¬ã¼ãã®æ´æ°ã¨ã®ä¸¡æ¹ããã£ãã·ã¥ã«å½±é¿ãã¾ããRails ã®å ´åã¯ãã£ãã·ã¥ãã¼ã«ãã³ãã¬ã¼ãã® digest ãå
¥ãããã«ãªãã¾ããï¼Rails 4 ãããªã®ã§ 10 å¹´åã§ããï¼ããã®ãããã§ãã³ã³ãã³ãã®æ´æ°ã ããèããã°è¯ããªã£ã¦ããã
ééçãªãã£ãã·ã¥
Webã¢ããªã±ã¼ã·ã§ã³ã®ãã£ãã·ã¥æ¦ç¥ã¨ãã®ãã¿ã¼ã³ ã§è¨ãã¨ããã® Broker ãã¿ã¼ã³ãPrimary ãªãã¼ã¿ã¹ãã¢ã«ã¢ã¯ã»ã¹ããåã« å¿
ã éããã£ãã·ã¥ã
ééçãªã®ã§å®è£
æã«èªèãã¥ããããããã°ãå²ã¨å°é£ãªããããã¾ãå°å
¥ããã¹ãã§ã¯ãªããããããã¨è¨ãã¨ãã«å
¥ããã¨ãã°ãå°ãªãè² è·ã軽æ¸ããããããã«ã¦ã§ã¢ãæãã ãã§å®ç¾ã§ããã®ãã¾ãããããã¨ããã¨ãã«å¹ãã
æåããè¨è¨ãã¦ããªãã¨ãªãã¼ãããã¾ã§ææ°æ
å ±ã表示ãããªãçã®å¯ä½ç¨ãåºãã®ã§ããããªãå°å
¥ããã®ã¯é常æã®æ段ã
Read Through CacheãWrite Through Cache ã¨å¼ã°ãããã¨ããããèªã¿è¾¼ã¿æã®ã¿ãªãããæ¸ãè¾¼ã¿æã Broker ãä»ãã¦æ¸ãè¾¼ãå ´åãããããããããã¨æ¸ãè¾¼ã¿ç´å¾ã®ãã£ãã·ã¥ãå¿
ãææ°ãä¿ã¦ããã常ã«ããã«ã©ã¤ãããã®ã¯ç¡é§ã«ãªããã¨ãå¤ãã
Broker ã§ã¯ãªããããã¼ã¿ã¹ãã¢ã®ã¬ããªã±ã¼ã·ã§ã³ãå©ç¨ãã¦ã® Read/Write Splitting ãç¹å¾´ãããªãä¼¼ããã£ãã·ã¥å½¢æ
ã ãããRead/Write Splitting ãé£ã³éå
·ã¨ãã¦æ©è½ãããã¨ãå¤ãã
ã¬ããªã±ã¼ã·ã§ã³ã§ããã°ããæ®æ®µã¯ replica åãã® connection ã使ããä¿åç³»ã®ã¯ã¨ãªã¯ primary ã«åãããã®ãªã¯ã¨ã¹ãã®ç¶ã or ãã®ã¦ã¼ã¶ã®æ°ç§ä»¥å
ã®ãªã¯ã¨ã¹ãã§ã¯èªã¿è¾¼ã¿ç³»ã®ã¯ã¨ãªã§ã primary åãã® connection ã使ããã®ãã㪠connection pooling ã®ä»çµã¿ãããã¨ãå¯ä½ç¨ãæå°éã«ãã¦ããæãã«æ±ãããããããªããRails ã®è¤æ° DB ã¯ããã§ãã¦ããã®ã§ããã¡ããã³ã¼ããèªãã®ããªã¹ã¹ã¡ãã¾ãã
ã¢ããªã±ã¼ã·ã§ã³çã«èªåã§å
¥ãããã£ãã·ã¥
ãããè³å¦ä¸¡è«ããã¤ãã§ããããã麻è¬ã§ããä¸æã«å
¥ããã¨æ¬å½ã«å°ãã
ãã£ãã·ã¥ ã¢ãµã¤ã ãã¿ã¼ã³ - Azure Architecture Center | Microsoft Learn ã¨è¨ãããã
Caching Strategies and How to Choose the Right One | CodeAhoy ã Webã¢ããªã±ã¼ã·ã§ã³ã«ãããæ£ãããã£ãã·ã¥æ¦ç¥ - Sansan Tech Blog ã§ãåãååãå½ã¦ããã¦ãã¾ããã
ã¢ããªã±ã¼ã·ã§ã³ã³ã¼ãå
ã®ããããç®æã§ãã®å¶å¾¡ãå
¥ãããã¨ããã°ããã£ã¨ããéã«ã«ãªã¹ã«ãªãã¾ãã
ãæ¬å½ã«ãããªã®ã§ããã®ãã¿ã¼ã³ã使ç¨ããã¨ãã¯è¢«å®³ãæå°éã«é£ãæ¢ããè¨è¨ã¨ä¸ç·ãããªãã¨æ»ã§ããç¡è¨ç»ã«ãã£ã¦ããã¨ã50 åãè¶ãã辺ãããä¸åãªèããæ¼ã£ã¦ããã ããããã®è¾ºãããæå³ããå¤æ®µãã£ãã·ã¥ã«ãªã£ã¦ãã¾ããã©ãã®ãã£ãã·ã¥ããã¼ã¸ãå¿ãã¦ããããã§ãã¼ã¿ãæ´æ°ãããªãã®ãã追ããªããªã£ã¦ããã
ä»ã«ãè²ã
HTTP ãã£ãã·ã¥ã¯ Webé
ä¿¡ã®æè¡ ã«ãã¹ã¦ãæ¸ãã¦ããã
ã¾ããããã³ãã¨ã³ãã®ãã£ãã·ã¥ããã£ã±ã話é¡ã¯ããï¼Apollo Client ã®ãã£ãã·ã¥ã¨ããNext.js ã®ãã£ãã·ã¥ã¨ãããããã㧠30 åãã¼ã¯ãã§ãã¡ããï¼ãã ãã©ãåãããã¾ãå°éãããªãã®ã§ä»ã®äººã«ãä»»ããã¾ãã
ã¨ããã§ã¦ã¼ã¶ãªã¯ã¨ã¹ãèµ·å ã§ãã£ãã·ã¥ãã¦ããã¨ãã£ãã·ã¥ãã¼ã¸æã«é常ã«å°ãã¨ãã話ã以åããã®ã§ããã¡ããåèã«ã©ããã
onk.hatenablog.jp
æ¸ãã¦ãããªããã°ãããªã宣ä¼
ãã®ã¨ã³ããªã®éª¨æ ¼ã¯ YAPC::Hiroshima 2024 ã« CfP ãåºãã ãã®ã§ãããããªãã¨åå¤ç¥ã§ãid:Soudai ããã¨ä¸ç·ã«è©±ããã¨ã«ãªãã¾ãããããã¾ã§ãä¸æ·ãã¨ãã¦ãæ´ã«æ·±ã話ããã¾ãã
ã¾ã ãã±ãããè³¼å
¥å¯è½ãªã®ã§ããã²æ¥ã¦ãã ããã
ã¾ã¨ã
ãã£ãã·ã¥ã¯éº»è¬ã¨è¨ããã¦ãã¾ããã絶対ã«é¿ããªããã°ãããªããã®ã§ã¯ããã¾ãããæ´åæ§ãå£ãããããªããã¨ãåé¡ãªã®ã§ããããã§ãã£ãã·ã¥ã®å¹¾ã¤ããåé¡ããããã¯ä½¿ã£ã¦ãè¯ããã£ãã·ã¥ã§ãããã¨ãããã¿ã¼ã³ãæãã¾ãããã¾ãã使ãã¨å¾ä¸ã§å°ããã¡ãªãã£ãã·ã¥ã«ã¤ãã¦ãæ°ãä»ãããã¤ã³ãï¼ä¸»ã«ãã£ãã·ã¥ã¢ãµã¤ããã¿ã¼ã³ã§å¤æ®µãã£ãã·ã¥ã«ãªãã®ãåé¡ã§ããï¼ãæ¸ãã¦ã¿ã¾ããã
ï¼¼ãã£ãã·ã¥ã¨ä¸æã«ä»ãåããï¼ï¼
ã¯ã¦ãª Advent Calendar 2023ãææ¥ã¯ id:tokizuoh ããã§ãã
åè URL