ããã£ãŒããããã®ç®ãéããŠãã£ãã·ã¥ïŒ
ãã£ãã·ã¥ã¯çµ±åã·ã¹ãã ã§ãã ãããã£ãŠãç°ãªãè§åºŠã§ã¯ãçµæã¯å®é åãšèé åã®äž¡æ¹ã«ååšããå¯èœæ§ããããŸãã åŸ
ã£ãŠãããã®ãšæ¬åœã«æã£ãŠãããã®ã®éããç解ããããšã¯éåžžã«éèŠã§ãã
ç¶æ³ãäžžããšã¹ã¯ããŒã«ããŠã¿ãŸãããã
Tl; drïŒã¢ãŒããã¯ãã£ã«ãã£ãã·ã¥ãè¿œå ãããšãããã£ãã·ã¥ã¯è² è·ã®ããã£
ãã·ã¹ãã ã
äžå®å®ã«ããæ段ã«ãªãåŸãããšãæ確ã«èªèããããšãéèŠã§ãã èšäºã®æåŸãã芧ãã ããã
çºæ¿ã¬ãŒããè¿ãããŒã¿ããŒã¹ã«ã¢ã¯ã»ã¹ã§ãããšããŸãã
rates.example.com/?currency1=XXX¤cy2=XXXã«åãåããããšãããã«å¿ããŠã³ãŒã¹ã®ãã¬ãŒã³ããã¹ãå€ãååŸããŸãã ããšãã°ãããŒã¿ããŒã¹ãžã®1000ã¯ãšãªããšã«1ãŠãŒãã»ã³ãããããŸãã
ããã§ãç§ãã¡ã®ãŠã§ããµã€ãã§ãã«ãããŠãŒããžã®çºæ¿ã¬ãŒãã衚瀺ããããšæããŸãã ãããè¡ãã«ã¯ãã³ãŒã¹ãååŸããå¿
èŠããããŸãããã®ããããã®ãµã€ãã§ã¯ã䟿å©ã«äœ¿çšã§ããAPIã©ãããŒãäœæããŠããŸãã
ããšãã°ã次ã®ããã«ïŒ
<?php
ãããŠãé©åãªå Žæã®ãã³ãã¬ãŒãã«æ¬¡ã®ãããªãã®ãæ¿å
¥ããŸãã
{{ get_current_rate("USD","EUR")|format(".2f") }} USD/EUR
ïŒãŸãããããã¯
<?=sprintf(".2f", get_current_rate("USD","EUR"))?>
ã§ãããããã¯æåŸã®äžçŽã§ãïŒã
Naiveå®è£
ã¯ãèããããæãåçŽãªããšãè¡ããŸããåãŠãŒã¶ãŒãããªã¢ãŒãã·ã¹ãã ãèŠæ±ãããã®çããçŽæ¥äœ¿çšããŸãã ããã¯ãçŸåšãç§ãã¡ã®ããŒãžã®ãŠãŒã¶ãŒã«ãã1000åã®ãã¥ãŒããšã«ãããã«å€ãã®è²»çšãããã£ãŠããããšãæå³ããŸãã ããã¯èŠããã ãã-ãããŒã ãããããããžã§ã¯ãã¯æé·ããŠããŸããæ¯æ¥1,000人ã®ãŠãŒã¶ãŒãæ¯æ¥ãµã€ãã«ã¢ã¯ã»ã¹ãããããã20ããŒãžãé²èŠ§ããŠããŸããããã¯æ¢ã«æé¡6ãŠãŒãã§ããããã«ããããµã€ãã¯
ç¡æããæãå®äŸ¡ãªå°çšä»®æ³ãµãŒããŒãžã®æ¯æãã«å®å
šã«å¹æµããŸãã
Maäžãã£ãã·ã¥äžè¬ã«ããã®æ
å ±ãããã»ã©é »ç¹ã«å¿
èŠãšãããªãå ŽåãããŒãžã®æŽæ°ããšã«åãŠãŒã¶ãŒã®ã³ãŒã¹ãå°ããå¿
èŠãããã®ã¯ãªãã§ããïŒ ãªãã¬ãã·ã¥ã¬ãŒãããããšãã°5ç§ã«1åã«å¶éããŠã¿ãŸãããã ããŒãžããããŒãžã«ç§»åãããŠãŒã¶ãŒã«ã¯æ°ããçªå·ã衚瀺ããã1000åã®1ã®éé¡ãæ¯æãããŸãã
ããã«èšã£ãŠãã£ãïŒ ããã€ãã®è¡ãè¿œå ããŸãã
<?php function get_current_rate($currency1, $currency2) { $cache_key = "rate_".$currency1."_".$currency2;
ããã¯ãã£ãã·ã¥ã®æãéèŠãªåŽé¢ã§ãã
æåŸã®çµæãä¿åããŸãã
ãããŠåºæ¥äžããïŒ ãã®ãµã€ãã¯åã³ç¡æã«ãªããŸã...ææ«ãŸã§ãå€éšã·ã¹ãã ãã4ãŠãŒãã®å£åº§ãçºèŠãããŸã§ã ãã¡ããã6ã§ã¯ãããŸãããã倧å¹
ãªç¯çŽãæåŸ
ã§ããŸãã
幞ããªããšã«ãå€éšã·ã¹ãã ã䜿çšãããšãèŠè¶ãé¡ã確èªã§ããŸããããã§ã¯ãåºåžçã®ããŒã¯æã«æ£ç¢ºã«5ç§ããšã«100以äžã®èŠæ±ã®ããŒã¹ãã衚瀺ãããŸãã
ãããããã£ãã·ã¥ã®2çªç®ã®éèŠãªåŽé¢ã§ãã
ã¯ãšãªéè€æé€ãå°å
¥ããæ¹æ³ã§ãã å®éã®ãšãããå€ãå€ããªã£ãããçµæããã£ãã·ã¥ã«ãããã©ããã確èªããŠããæ°ããå€ãä¿åãããŸã§ã«ããã¹ãŠã®çä¿¡èŠæ±ã¯å®éã«å€éšã·ã¹ãã ãžã®èŠæ±ãåæã«å®è¡ããŸãã
memcacheã®å Žåãããã¯ãããšãã°æ¬¡ã®ããã«å®è£
ã§ããŸãã
<?php function get_current_rate($currency1, $currency2) { $cache_key = "rate_".$currency1."_".$currency2; $memcache = new Memcache(); $memcache->addServer("localhost", 11211); while (true) { $rate = $memcache->get($cache_key); if ($rate == "?") { sleep(0.05); } else if ($rate) { return $rate; } else {
ãããŠæåŸã«ãæ¶è²»ã¯äºæ³ãšåçã§ãã-5ç§ã§1ãªã¯ãšã¹ããè²»çšã¯1ãæããã2ãŠãŒãã«åæžãããŸããã
ãªã2ã§ããïŒ äœå人ããã£ãã·ã¥ãªãã§6ã€ãããŸãããããã¹ãŠããã£ãã·ã¥ããŸãããã3åããæžå°ããŸããã§ãããïŒ ã¯ããæ©ãã«èšç®ãã䟡å€ããããŸãã... 5ç§ã«1å= 1åããã12 = 1æéããã72 = 1ãæããã576 = 1ãæããã1äž7,000人ã§ã誰ããã¹ã±ãžã¥ãŒã«ã«æ²¿ã£ãŠããããã§ã¯ãªããå€é
ãã«èŠãŠããå¥åŠãªäººãããŸã...äœçŸãã®ã³ãŒã«ã®ä»£ããã«ãããŒã¯ã1ã€ã ããããéããªæéã«ã以åãšåæ§ã«ãã»ãšãã©ãã¹ãŠã®ã³ãŒã«ã®ãªã¯ãšã¹ããééããŸãã ããã§ããææªã®å Žåã§ããã¹ã³ã¢ã¯31Ã86400÷5 = 5.36ãŠãŒãã§ããå¿
èŠããããŸãã
ããã§ãå¥ã®åŽé¢ã«åºäŒããŸããããã£ãã·ã¥
ã¯ãå©ããŸãã
ãè² è·ã
æé€ããŸãã ã
ããããç§ãã¡ã®å Žåã人ã
ã¯ãããžã§ã¯ãã«æ¥ãŠç«ã¡å»ããããæç¹ã§ãã¬ãŒãã«ã€ããŠäžå¹³ãèšãå§ããŸããæ°ç§éããŒãžãããªãŒãºããŸãã ãŸããååäžã«ãµã€ãããŸã£ããå¿çããªãå ŽåããããŸã...
ãµã€ãã®ã³ã³ãœãŒã«ã衚瀺ãããšãååŸã«è¿œå ã®ã€ã³ã¹ã¿ã³ã¹ãèµ·åãããããšããããŸãã åæã«ãã¯ãšãªã®å®è¡é床ã¯ãªã¯ãšã¹ãããšã«5ã15ç§ã«äœäžããŸã-ãããèµ·ããããã§ãã
èªè
ã®ããã®ç·Žç¿ïŒåã®ã³ãŒãã泚ææ·±ãèŠãŠãçç±ãèŠã€ããŠãã ãããã¯ããã¯ããã¯ãã ãã¡ãããããã¯
if ($rate === FALSE)
ãã©ã³ãã«ãããŸãã å€éšãµãŒãã¹ããšã©ãŒãè¿ããå Žåãããã¯ã解é€ããŸããã§ãã...ãšããæå³ã§ãïŒã èšé²ããããŸãŸã§ã誰ãããããé³è
åããã®ãåŸ
ã£ãŠããŸãã ããã¯ç°¡åã«ä¿®æ£ã§ããŸãã
if ($rate === FALSE) { $memcache->delete($cache_key); return $rate; } else {
ã¡ãªã¿ã«ããã®ã¬ãŒãã¯åãªããã£ãã·ã¥ã§ã¯ãªããåæ£ããã¯ã®äžè¬çãªåŽé¢ã§ãããããããã¯ãåé¿ããããã«ãããã¯ã解é€ããŠã¿ã€ã ã¢ãŠããèšå®ããããšãéèŠã§ãã ãïŒããè¿œå ããå Žå 寿åœããªããšãå€éšã·ã¹ãã ãšã®éä¿¡ã®æåã®ãšã©ãŒã§ãã¹ãŠãããªãŒãºããŸãã æ®å¿µãªãããmemcacheã¯åæ£ããã¯ãäœæããããã®è¯ãæ¹æ³ãæäŸããŸãããè¡ã¬ãã«ã®ããã¯ãåããæ¬æ ŒçãªããŒã¿ããŒã¹ã䜿çšããæ¹ãåªããŠããŸãããããã¯åã«ãã®ã¬ãŒããèžãã ããã«å¿
èŠãªåæ
çãªäœè«ã§ããã
ãã®ãããåé¡ãä¿®æ£ããŸããããäœãå€ãã£ãŠããŸããããã¬ãŒãããŸã æã
èµ·åããŸããã 泚ç®ã«å€ããã®ã¯ã圌ããæè¡ã·ã¹ãã ã«é¢ããå€éšã·ã¹ãã ããã®ãã¥ãŒã¹ã¬ã¿ãŒãšæéçã«äžèŽããããšã§ã...
ãããã...ã¡ãã£ãšäŒæ©ããŠãä»éãããã®ããã£ãã·ã¥ãã§ããããšãæ¯ãè¿ããŸãããã
- æåŸã®æ¢ç¥ã®çµæãèŠããŠãããŠãã ããã
- çµæããŸã ãŸãã¯äžæã§ããå Žåã®ã¯ãšãªã®éè€æé€ã
- ãšã©ãŒãçºçããå Žåã«æ£ããããã¯è§£é€ã確èªããŠãã ããã
æ°ã¥ããïŒ ãã£ãã·ã¥ã¯ããšã©ãŒã®å Žåã«ãã€ã³ã1ã2ãæäŸããå¿
èŠããããŸãã æåã¯ãããã¯æãããªããã§ããäœãèµ·ãã£ãã®ãåãããã1ã€ã®èŠæ±ãèœã¡ã次ã®èŠæ±ãæŽæ°ãããŸãã ãããã次ã®ãã®ããšã©ãŒãè¿ããšã©ããªããŸããïŒ ãããŠæ¬¡ã¯ïŒ 10件ã®ãªã¯ãšã¹ãããããæåã®ãªã¯ãšã¹ããããã¯ãååŸããçµæãååŸããããšããŸããããèœã¡ãŠããŸããŸããã 次ã®ãã®ã¯ãã§ãã¯ããŸã-ãã®ãããããããã³ã°ãå€ããããŸãããçµæãæ±ããŸãã å·ŠæããŸããã ã ããçã®ããã«ã ãŸããæããªããšïŒ è¯ã10ãæ¥ãŠã1ã€ãè©ŠãããŸãã-ã¿ããªèœã¡ãŸããã ãããŠã次ã®ãã®ãããäžåºŠè©ŠããŠã¿ãŸãããïŒ
ãã®ããããã£ãã·ã¥ã¯ãã°ããã®é
åŠå®çãªçµæã
ä¿åã§ããªããã°ãªããŸããã åçŽãªåæã®ä»®å®ã¯ãæ¬è³ªçã«0ç§éãã¬ãã£ããªçµæãä¿åããããšãæå³ããŸãïŒãã ãããã®åŠå®ãæ¢ã«åŸ
ã£ãŠãããã¹ãŠã®äººã«éä¿¡ããŸãïŒã æ®å¿µãªãããMemcacheã®å ŽåããŒãã¬ã€ãã³ã·ã®å®è£
ã¯éåžžã«åé¡ããããŸãïŒåä»ãª
èªè
ã®å®¿é¡ãšããŠæ®ããŸããã¢ããã€ã¹ïŒ
CASã¡ã«ããºã ã䜿çšããŸããã¯ããAppEngineã§MemcacheãšMemcachedã䜿çšã§ããŸãïŒã
è² ã®å€ã1ç§ã®å¯¿åœã§ä¿åããã ãã§ãã
<?php function get_current_rate($currency1, $currency2) { $cache_key = "rate_".$currency1."_".$currency2; $memcache = new Memcache(); $memcache->addServer("localhost", 11211); while (true) { $flags = FALSE; $rate = $memcache->get($cache_key, $flags); if ($rate == "?") { sleep(0.05); } else if ($flags !== FALSE) {
ä»ã§ã¯ãã
ã ã㧠ãèœã¡çãããšãã§ããŸããïŒ ã©ããªã«ã ç§ãã¡ãæé·ããŠããéãç§ãã¡ã®ææã®å€éšãµãŒãã¹ãæé·ããŠããŸããããããŠããæç¹ã§ãããã¯æã
é
ããªããäžç¬ã§ãåå¿ãå§ããŸãã...ãããŠé©ãã¹ãããš-ãããšãšãã«ãç§ãã¡ã®ãŠã§ããµã€ããé
ããªãå§ããŸããïŒ ãããŠåã³çã®ããã«ïŒ ãããããªãã§ããïŒ ãšã©ãŒãçºçããå Žåããã¹ãŠããã£ãã·ã¥ãããšã©ãŒãèšæ¶ããããã«ãããåŸ
æ©äžã®å
šå¡ãäžåºŠã«è§£æŸããŸããïŒ
...ãããŠããã«ãããŸãã ããäžåºŠã³ãŒããããèŠãŠãã ããïŒ
file_get_contents()
ãèš±å¯ããéããå€éšã·ã¹ãã ãžã®ãªã¯ãšã¹ãã¯å®è¡ãããŸãã ãªã¯ãšã¹ãã®å®è¡æã«ã¯ä»ã®å
šå¡ãåŸ
æ©ããŠããããããã£ãã·ã¥ãå»æ¢ããããã³ã«ããã¹ãŠã®ã¹ã¬ãããã¡ã€ã³ã¹ã¬ããã®å®è¡ãåŸ
æ©ããå°çãããšãã«ã®ã¿æ°ããããŒã¿ãåä¿¡ããŸãã
ãŸããåŸ
æ©ãã代ããã«ã
memcache->add
...ã®åšãã®æ¡ä»¶ã«
else{}
ãã©ã³ãã
memcache->add
ãŸããæ¬åœã§ããæåŸã®æ¢ç¥ã®å€ãè¿ãå¿
èŠããããŸãããïŒ çµå±ãæ°ããæ
å ±ããªãå Žåãå€ãæ
å ±ãåä¿¡ããããšã«åæããããšãæ£ç¢ºã«ãã£ãã·ã¥ããŸãã ãã®ããããã1ã€ã®ãã£ãã·ã¥èŠä»¶ããããŸããèŠæ±ã1ã€ã ã
é
ããªãããã«ããŸãã
ããã«èšã£ãŠãã£ãïŒ
<?php function get_current_rate($currency1, $currency2) { $cache_key = "rate_".$currency1."_".$currency2; $memcache = new Memcache(); $memcache->addServer("localhost", 11211); while (true) { $flags = FALSE; $rate = $memcache->get($cache_key, $flags); if ($rate == "?") { sleep(0.05); } else if ($flags !== FALSE) { return $rate; } else { if ($memcache->add($cache_key, "?", 0, 5)) { $api_host = "http://rates.example.com/"; $args = http_build_query(array("currency1"=>$currency1, "currency2"=>$currency2)); $rate = @file_get_contents($api_host."?".$args); if ($rate === FALSE) {
ããã§ãç§ãã¡ã¯åã³åã¡ãŸãããå€éšãµãŒãã¹ãé
ããªã£ãŠãã1ããŒãžããé
ããªããŸãã...ã€ãŸããå¹³åå¿çæéãççž®ãããããã«ããŠãŒã¶ãŒã¯ãŸã å°ãäžæºã§ãã
泚ïŒéåžžã®PHPã¯ããã©ã«ãã§ã»ãã·ã§ã³ããã¡ã€ã«ã«æžã蟌ã¿ãåæãªã¯ãšã¹ãããããã¯ããŸãã ãã®åäœãåé¿ããã«ã¯ãread_and_closeãã©ã¡ãŒã¿ãŒãsession_startã«æž¡ãããå¿
èŠãªãã¹ãŠã®å€æŽãè¡ãããåŸãsession_closeã§ã»ãã·ã§ã³ã匷å¶çã«éããŸããããããªããšã1ã€ã®ããŒãžãé
ããªãã®ã§ã¯ãªãã1人ã®ãŠãŒã¶ãŒïŒå€ãæŽæ°ããã¹ã¯ãªãããåãããã®å¥ã®èŠæ±ã«ãã£ãŠã»ãã·ã§ã³ã®éå§ããããã¯ãããããŠãŒã¶ãŒã AppEngineã§å®è¡ããããš
ãmemcacheã®ã»ãã·ã§ã³ã¹ãã¬ãŒãžã¯ããã©ã«ãã§æå¹ã«ãªããŸããã€ãŸããããã¯ãªãã§ãããããåé¡ã¯ããã»ã©ç®ç«ã¡ãŸããã
ãããã£ãŠããŠãŒã¶ãŒã¯ãŸã äžæºã§ãïŒããããããã®ãŠãŒã¶ãŒïŒïŒã ãµã€ãã§æãæéãè²»ãããŠãã人ã¯ããããã®çããã³ã°ã«ãŸã æ°ã¥ããŠããŸãã ãããŠã圌ãã¯ããããã£ãã«èµ·ãããªããšããäºå®ã«ãŸã£ããæºè¶³ããŠããããåã«å¹žéã§ã¯ãããŸããã
ãã®å ŽåãèŠä»¶ãããã«å³ãã
ããå¿
èŠããããŸã ã
èŠæ±ã¯å¿çãåŸ
ã€ã¹ãã§ã¯ãããŸãã ã
ãã®è³ªåã®å®åŒåã§ã¯äœãã§ããŸããïŒ ã§ããããšïŒ
- ã å¿çåŸã®å®è¡ ãããªãã¯ãå®è¡ããŠã¿ãŠãã ãããã€ãŸããå€ãæŽæ°ããå¿
èŠãããå Žåã¯ãã¹ã¯ãªããã®æ®ãã®å®è¡åŸã«ãããè¡ããã³ãã©ãŒãç»é²ããŸãã ã¢ããªã±ãŒã·ã§ã³ãšå®è¡ç°å¢ã«äŸåããŸãã æãä¿¡é Œã§ããæ¹æ³ã¯
fastcgi_finish_request ()
ã䜿çšããããšfastcgi_finish_request ()
ãããã«ã¯php- fastcgi_finish_request ()
ãµãŒããŒæ§æãå¿
èŠã§ãïŒãããã£ãŠãAppEngineã§ã¯äœ¿çšã§ããŸããïŒã
- åå¥ã®ã¹ã¬ããã§æŽæ°ãè¡ããŸãïŒã€ãŸãã
pcntl_fork()
å®è¡ãããã system()
ãŸãã¯ä»ã®äœããä»ããŠã¹ã¯ãªãããå®è¡ããŸãïŒ-åã³ããµãŒããŒã§æ©èœããå Žåã«ãã£ãŠã¯ã»ãã¥ãªãã£ãããŸãæ°ã«ããªãå
±æãã¹ãã£ã³ã°ãµãŒãã¹ã§ãæ©èœããŸãããããããã¡ãããåŠæ³çãªã»ãã¥ãªãã£ã®ãµãŒãã¹ã§ã¯æ©èœããŸãããã€ãŸããAppEngineã¯é©åã§ã¯ãããŸããã
- ãã£ãã·ã¥ãæŽæ°ããããã«åžžã«å®è¡ãããŠããããã¯ã°ã©ãŠã³ãããã»ã¹ããããŸããããã»ã¹ã¯ããã£ãã·ã¥å
ã®å€ãå€ããªã£ãŠãããã©ãããæå®ã®é »åºŠã§ç¢ºèªããå¿
èŠããããŸãããŸããåç¶æéãçµäºãããã£ãã·ã¥ã®åç¶äžã«å€ãå¿
èŠã«ãªã£ãå ŽåãæŽæ°ããŸãã ãã®ç¹ã«ã€ããŠã¯ãçºæ¿ã¬ãŒãã§è²§åŒ±ãªãµã€ãã«ãããããããã楜ãããã®ã«ç§»ããšãã«å°ãåŸã§èª¬æããŸãã
å®éã®ãšãããããŒã¿ãåžžã«ããããªç¶æ
ã«ç¶æããããšã¯ãã»ãã®æ°è¡ã®PHPã³ãŒããããå°ãè€éãªã¿ã¹ã¯ã§ãããã®ãããåçŽãªã±ãŒã¹ã§ã¯
ãããçš®ã®ãªã¯ãšã¹ããå®æçã«ãèãçŽãããããšããäºå®
ã«èããå¿
èŠããããŸãïŒã©ã³ãã ã§ã¯ãªããããã€ã;ã€ãŸãã
randomã§ã¯ãªãã
ä»»æã§ãã ã¿ã¹ã¯ãè©Šãã«ã¯ããã®ã¢ãããŒãã®é©çšæ§ã
åžžã«éèŠã§ãïŒ
ãã®ãããããŒã¿ãããã€ããŒã¯æé·ããŠããŸããããã¹ãŠã®é¡§å®¢ããããèªã¿åãããã§ã¯ãªããããæ£ãããã£ãã·ã³ã°ã䜿çšããïŒãŸã£ãã䜿çšããªãå ŽåïŒãããæç¹ã§èšå€§ãªæ°ã®èŠæ±ãçºè¡ãå§ããŸãã圌ã¯ãã£ãããšã ãã§ãªãã
éåžžã«ãã£ãããšçãå§ããŸãã æ°åç§ä»¥äžã ãã¡ããããŠãŒã¶ãŒã¯F5ããŒãæŒããããŒãžããªããŒãã§ããããšãããã«çºèŠããããã«è¡šç€ºãããŸã-å€éšã®å¿çãåã«åŸ
ã£ãŠããããªãœãŒã¹ãæ¶è²»ããããã»ã¹ããã³ã°ãå§ãããããããŒãžã®ã¿ãåã³ç¡æã®å¶éã«éãå§ããŸããã
ä»ã®å¯äœçšã®äžã§ããæ代é
ãã®ã³ãŒã¹ã瀺ãã±ãŒã¹ãããé »ç¹ã«ãªã£ãŠããŸãã [ããŒã...äžè¬çã«ãç§ãã¡ã®ã±ãŒã¹ã«ã€ããŠã§ã¯ãªããé³è
åãèçŒã§èŠããããè€éãªãã®ã«ã€ããŠè©±ããŠãããšæ³åããŠãã ãã:)å®éã«ã¯ãåçŽãªå Žåã§ãããã®ãããªå®å
šã«æçœãªåŠšå®³ã«æ°ä»ããŠãŒã¶ãŒãããã¯ãã§ã]ã
äœãèµ·ãããèŠãŠãã ããïŒ
- ãªã¯ãšã¹ã1ãæ¥ãŸããããã£ãã·ã¥ã«ããŒã¿ããªããããããŒã¯ã³ãïŒããè¿œå ããŸããã 5ç§éãã³ãŒã¹ã«è¡ããŸããã
- 1ç§åŸããªã¯ãšã¹ãçªå·2ãå±ããããŒã«ãŒãïŒãã衚瀺ãããå€ãã¬ã³ãŒãããããŒã¿ãè¿ãããŸããã
- 3ç§åŸããªã¯ãšã¹ãçªå·3ãå°çããããŒã«ãŒãïŒãã衚瀺ãããå€ãç¶æ
ãè¿ãããŸããã
- 1ç§åŸãããŒã«ãŒãïŒã èŠæ±1ããŸã å¿çãåŸ
æ©ããŠããå Žåã§ãéæšå¥šã§ãã
- ããã«2ç§åŸããªã¯ãšã¹ãçªå·4ãå°çããããŒã«ãŒã¯ãããŸãããæ°ããããŒã«ãŒãè¿œå ããŠãã³ãŒã¹ã«é²ã¿ãŸãã
- ...
- èŠæ±1ãå¿çãåä¿¡ããçµæãä¿åããŸããã
- ãªã¯ãšã¹ãXãå°çããæåã®è³ªåã®ãã£ãã·ã¥ããçŸåšã®åçãåãåããŸããïŒãããŠããã€ãã®åçãåŸãŸãããïŒãªã¯ãšã¹ãã®æç¹ã§ããŸãã¯åçã®ç¬éã«ïŒ-誰ãç¥ããŸãã...ïŒã
- ãªã¯ãšã¹ãçªå·4ã¯åçãåãåããçµæãä¿åããŸãã-ãããŠããã®åçãããæ°ãããå€ããã¯æ確ã§ã¯ãããŸãã...
ãã¡ãããããã§ã¯
stream_context_create
ini_set("default_socket_timeout")
䜿çšããŠå¿
èŠãªã¿ã€ã ã¢ãŠããèšå®ãããã
stream_context_create
䜿çšãã
stream_context_create
ãŸãããã®ãããå¥ã®éèŠãªåŽé¢
ããããŸã ã åäœã«å¯Ÿããäžè¬çãªè§£æ±ºçã¯ãããŸããããååãšããŠããã£ãã·ã¥æéã¯èšç®æéããé·ãããå¿
èŠããããŸãã èšç®æéããã£ãã·ã¥ã®æå¹æéãè¶
ããå Žåã
ãã£ãã·ã¥ã¯é©çšãããŸãã ã ããã¯ãã¯ããã£ãã·ã¥ã§ã¯ãªããä¿¡é Œã§ããã¹ãã¬ãŒãžã«ä¿åãããã¹ã
äºåèšç®ã§ãã
ããã§ã¯ãå°èšãèŠçŽããŸãããã åžžèã§ã¯ããã£ãã·ã¥ã¯æ¬¡ã®ããšãè¡ããŸãã
- æ¢ç¥ã®åçã«å¯Ÿããã»ãšãã©ã®èŠæ±ã眮ãæããŸãã
- é«äŸ¡ãªããŒã¿ã®ãªã¯ãšã¹ãæ°ãå¶éããŸãã
- ã¯ãšãªæéããŠãŒã¶ãŒã«èŠããªãããŸãã
ãã ããå®éã«ã¯ïŒ
- ãã£ãã·ã¥ã©ã€ããŠã£ã³ããŠããã®äžéšã®ãªã¯ãšã¹ããä¿åãããå€ã«çœ®ãæããŸãïŒããšãã°ãã¡ã¢ãªäžè¶³ãèŽ
æ²¢ãªãªã¯ãšã¹ããªã©ã«ããããã£ãã·ã¥ã¯ãã€ã§ã倱ãããå¯èœæ§ããããŸãïŒã
- èŠæ±ã®æ°ãå¶éããããšããŠããŸãïŒãã ããçºä¿¡èŠæ±ã®é »åºŠã®å¶éãç¹å¥ã«å®è£
ããªããã°ããäžåºŠã«æ倧1ã€ã®çºä¿¡èŠæ±ãã¿ã€ãã®ç¹æ§ã®ã¿ãæäŸããããšãå®éã«å¯èœã§ãïŒã
- ã¯ãšãªã®å®è¡æéã¯äžéšã®ãŠãŒã¶ãŒã«ã®ã¿è¡šç€ºãããŸãïŒããã«ãã幞éãªãŠãŒã¶ãŒãã¯æ±ºããŠåçã«åæ£ãããŠããŸããïŒã
ãã£ãã·ã¥ã¯ãä¿åãããããŒã¿ã®ãäžææ§ããæå³ããããããã£ãã·ã³ã°ã·ã¹ãã ã¯ãäžè¬çã«ã©ã€ãã¿ã€ã ãšããŒã¿ãä¿åãããªã¯ãšã¹ãã®äºå®ãèªç±ã«åŠçã§ããŸãã
- ãã£ãã·ã¥ã¯ãã€ã§ã倱ãããå¯èœæ§ããããŸãã å®è¡ããã¯ããŒã«ãŒããïŒãã§ãã åããã£ãã·ã¥ãµãŒããŒäžã«ããã»ãã·ã§ã³ã«äœãïŒå€ãã®å Žåããµã€ããžã®æåŸã®ã¢ã¯ã»ã¹ã®æéïŒãä¿åããªãããããã«1äžäººã®ãŠãŒã¶ãŒããµã€ããæ©ãåããšã倱ãããå ŽåããããŸãã ããŒã¯ã³ã倱ãããïŒããã£ãã·ã¥ãã€ãºãã³ã°ãïŒåŸã次ã®ãªã¯ãšã¹ãã¯åã³ãã£ãã·ã¥å
ã®å€ãæŽæ°ããããã»ã¹ãéå§ããŸãã
- ãªã¢ãŒãã·ã¹ãã ã§ãªã¯ãšã¹ããé«éã«å®è¡ãããã»ã©ããã£ãã·ã¥ãã€ãºãã³ã°ã®å Žåã«éè€æé€ããããªã¯ãšã¹ããå°ãªããªããŸãã
ãããã£ãŠãåã«ãã£ãã·ã¥ãé©çšããã ãã§ãä¿çäžã®ã¢ã¯ã·ã§ã³ã®é±å±±ã眮ãããšããããŸãããããã¯ç¢ºãã«ççºããŸã-ããããä»ã§ã¯ãªããå°æ¥ã決å®ã«ã¯ããã«è²»çšãããããŸãã ã·ã¹ãã ã®ããã©ãŒãã³ã¹ãèšç®ãããšãã¯ãè¯å®çãªå¿çããã£ãã·ã¥ããããšã«ããå®è¡æéã®ççž®ãèæ
®ããã«èæ
®ããããšãéèŠã§ãã
æãåçŽãªã±ãŒã¹ãèããŠã¿ãŸãããã
- ç©ãããªç¶æ
ã®ã·ã¹ãã ãèŠããšãå¹³åå®è¡æéã¯0.05ç§ã§ãã
- çµè«ïŒ1ã€ã®ããã»ã¹ã§1ç§ããã20ã®ãªã¯ãšã¹ããåŠçã§ããŸããã€ãŸãã1ç§ããã100ã®ãªã¯ãšã¹ãã§ã¯5ã€ã®ããã»ã¹ã§ååã§ãã
- ãã ãããªã¯ãšã¹ãã®æŽæ°æéã2ç§ã«å¢å ããå Žåã®ã¿ã次ã®ããã«ãªããŸãã
- 1ã€ã®ããã»ã¹ãæŽæ°äžã§ãïŒ2ç§ä»¥å
ïŒã
- ãã®2ç§éã§å©çšã§ããããã»ã¹ã¯4ã€ã ãã§ã1ç§ããã80ãªã¯ãšã¹ãã§ãã
ãŸããè² è·ãé«ãå Žåããã£ãã·ã¥ã¯ãã€ãºãã³ã°ããããªã¯ãšã¹ãã¯5ç§éãã£ãã·ã¥ãããŸãããã1ç§éã®ã¿ãã£ãã·ã¥ãããŸããã€ãŸãã2ã€ã®ãªã¯ãšã¹ããåžžã«ããžãŒç¶æ
ã«ãªããŸãïŒæåã®ãªã¯ãšã¹ããå®è¡ãã ïŒãã¡ã³ããã³ã¹ã®æ®ãã®å®¹éã¯1ç§ããã60ãªã¯ãšã¹ãã«åæžãããŸãã ã€ãŸãã1åããã6000ãªã¯ãšã¹ãïŒå¹³åã«åºã¥ãïŒã®æå¹å®¹éã¯ã3600ã«æ¥èœããŸãã ã€ãŸããæ¯å5,000ãªã¯ãšã¹ãã§ãã€ãºãã³ã°ãçºçãããšãè² è·ã5,000ãã3,000ã«äœäžãããŸã§ãã·ã¹ãã ã¯äžå®å®ã«ãªããŸãã ã€ãŸãããã©ãã£ãã¯ã®æ¥å¢ã¯ãé·æçãªã·ã¹ãã ã®äžå®å®ãåŒãèµ·ããå¯èœæ§ããããŸãã
ããã¯ãæ°æ©èœãåãããã¥ãŒã¹ã¬ã¿ãŒã®åŸã«ããŠãŒã¶ãŒã®æ³¢ãã»ãŒåæã«å±ãå Žåã«ãç¹ã«çŽ æŽãããèŠããŸãã å®æçãªããŒã±ãã£ã³ã°habraeffectã®äžçš®ã
ããã¯ãã¹ãŠããã£ãã·ã¥ã䜿çšã§ããªãããŸãã¯äœ¿çšããããšãæ害ã§ããããšãæå³ãããã®ã§ã¯ãããŸããïŒ , , , .