ãPerlã¡ã¢ãã®æä»å¶å¾¡ãã¸ãã¯ãPHPã«ç§»æ¤ãã¦ã¿ã
PHPã«ãããæä»å¶å¾¡ã®ãã¹ããã©ã¯ãã£ã¹ãåãããªãã£ãã®ã§ãå®è©ã®ãããããªãPerlメモãã®ã排他制御(ファイルロック)をするãã移æ¤ãã¦ã¿ã¾ããã誤ããããããããã¾ããã®ã§ããæ°ã¥ãã®æ¹ã¯ãææããã ããã¨å©ããã¾ãã
<?php function my_flock($options = array()) { $lfh = array_merge(array('dir' => './lockdir/', 'basename' => 'lockfile', 'timeout' => 60, 'trytime' => 10), $options); $lfh['path'] = $lfh['dir'] . $lfh['basename']; for ($i = 0; $i < $lfh['trytime']; $i++, sleep(1)) { if (rename($lfh['path'], $lfh['current'] = $lfh['path'] . time())) { return $lfh; } } $filelist = scandir($lfh['dir']); foreach ($filelist as $file) { if (preg_match('/^' . $lfh['basename'] . '(\d+)/', $file, $matches)) { if (time() - $matches[1] > $lfh['timeout'] and rename($lfh['dir'] . $matches[0], $lfh['current'] = $lfh['path'] . time()) ) { return $lfh; } break; } } return false; } function my_funlock($lfh) { rename($lfh['current'], $lfh['path']); } # ããã¯ãã(ã¿ã¤ã ã¢ã¦ããã) $lfh = my_flock() or die('Busy!'); # ã¢ã³ããã¯ãã my_funlock($lfh);
æä»å¶å¾¡ã®ç®çã§ãããWebãµã¼ãã¹ã®APIãå¼ã³åºãéã®ã¤ã³ã¿ã¼ãã«ç®¡çã«ä½¿ãã¤ããã§ãããã¨ãã°ãAmazon Associates Web Serviceã®APIã«ã¯ã1ç§1ã³ã¼ã«ã¾ã§ã¨ããå¶éãããã¾ãããããéµå®ããããã«ã¯ãæçµå¼ã³åºãæå»ãä¿æãã¤ã¤ããããã¢ãããã¯ã«æ´æ°ããä»çµã¿ãå¿ è¦ã«ãªãã§ãããã
ã¡ãªã¿ã«ãæä½ã®リリースチェッカーã«ããã®ãããªä»çµã¿ã¯ããã®ã§ãããPerlã¡ã¢ã®ãã¸ãã¯ã«æ¯ã¹ãã¨ä¸éå端ãªæããªã®ã§ãæ¹åãããã¨æã£ã¦ããããã§ãã