Àá±ñ ±¹³»ÀÇ À¥¼ºñ½º¿Í »ç¿ëÀÚ¿¡ ´ëÇÏ¿© °£´ÜÇÏ°Ô À̾߱â ÇØ º¼±î¿ä. ÀϹ湮ÀÚ°¡ 10,000¸íÀÌ µÇ´Â »çÀÌÆ®ÀÇ °æ¿ì´Â ½Ã°£´ç ¾à 420¸í, ºÐ´ç 7¸í, ÃÊ´ç 0.1¸í Á¤µµ°¡ ¹æ¹®ÇÏ°Ô µË´Ï´Ù. Æò±ÕÀûÀ¸·Î ÇѸíÀÇ ¹æ¹®ÀÚ°¡ 10ÆäÀÌÁö¸¦ Á¶È¸ÇÑ´Ù°í ÇßÀ» °æ¿ì¿¡µµ ÇØ´ç »çÀÌÆ®´Â ½Ã°£´ç 4,200 Á¤µµÀÇ TransactionÀÌ ¹ß»ýÇÏ°Ô µË´Ï´Ù. Peak-TimeÀ» °í·ÁÇÑ´Ù°í ÇØµµ ±×·¸°Ô Å« ¼ýÀÚ´Â µÇÁö ¾Ê½À´Ï´Ù. ¾ÈÁ¤¼ºÀ» °í·ÁÇÏÁö ¾Ê°í ÀÏ¹Ý Content ±â¹ÝÀÇ ¼ºñ½º¶ó°í »ý°¢ÇÒ¶§ Intel Pentium4 [2.0G] Á¤µµÀÇ ÁßÀú±ÞÀÇ ¼¹ö¸é ÃæºÐÈ÷ ¼ºñ½º ÇÒ¼ö ÀÖ´Â ¼ýÀÚÀÔ´Ï´Ù. ±×¸®°í ÀϹ湮ÀÚ°¡ ¸¸¸íÁ¤µµ µÇ´Â »çÀÌÆ®´Â ±¹³»¿¡´Â ¾à 1500°³Á¤µµ ¹Û¿¡ µÇÁö ¾Ê±¸¿ä.
À§¿Í °°Àº ÀÌÀ¯·Î ´ëºÎºÐÀÇ ±¹³»»çÀÌÆ®´Â Å©°Ô ¼º´É°ú ·Îµù ¼Óµµ°¡ ¹®Á¦°¡ µÇÁö ¾Ê½À´Ï´Ù. ¸¸¾à ¹®Á¦°¡ µÈ´Ù¸é ÇÁ·Î±×·¥À» À߸ø ÀÛ¼ºÇ߰ųª ¾Æ´Ô ¸¹Àº ¼öÀÍÀ» ¹ß»ýÇϰųª µÑÁß Çϳª ÀϰÍÀÔ´Ï´Ù. ±×·¯³ª ¸ÞÀÎÆäÀÌÁö,DB Á¢¼ÓÀ» ÅëÇÏ¿© ´Ù·®ÀÇ ÀÚ·á °Ë»öÀ» ÇØ¾ß ÇÏ´Â °æ¿ì ±×¸®°í º¹ÀâÇÑ ¿¬»êÀ» ¼öÇàÇÏ´Â °æ¿ì¿Í °°Àº Web Application Àº ´ÜÀÏ ¿äû¿¡ ´ëÇÏ¿©µµ ¸¹Àº ºÎÇÏ¿Í ÀÌ¿¡ µû¸¥ °á°ú·Î ·Îµù ¼Óµµ°¡ ´À·ÁÁö°Ô µÇ¾î ¿øÇÒÇÑ ¼ºñ½º¸¦ Á¦°øÇϴµ¥ ¹®Á¦°¡ ÀÖ½À´Ï´Ù. ÀÌ·± °æ¿ì¿¡ Cache ±â¼úÀ» À¯¿ëÇÏ°Ô »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.
Cahce ±â¼úÀº ¾Æ·¡¿Í °°Àº Á¦ÇÑÁ¡ÀÌ ÀÖÁö¸¸ Àß ÀÀ¿ëÇÏ°Ô µÇ¸é °æÀï »çÀÌÆ® º¸´Ù 10¹è ´õ ºü¸£°Ô °í°´¿¡¼ ³ª°¡°¥¼ö ÀÖ½À´Ï´Ù.
demo.php
<?php require "lib/jmrss/URLCache.php"; // Cache Àû¿ëÇϱâ Cache(true,"./cache",3600); // Database ¿¬°á $conn = mysql_connect("mysql.ihelpers.co.kr", "xxxxx", "xxxxx"); mysql_select_db("xxxxx",$conn); $sql = "SHOW TABLES"; $result = mysql_query($sql,$conn); echo "<pre>"; while($row = mysql_fetch_array($result)){ print_r($row); } echo "</pre>"; mysql_close($conn); ?>
±âÁ¸ÀÇ Web Application¿¡ Cache ¸ðµâÀ» Àû¿ëÇÏ´Â ¹æ¹ýÀº »ó´çÈ÷ °£´ÜÇÕ´Ï´Ù. URLCache.php ÆÄÀÏÀ» include Çϰí CacheÇÔ¼ö¸¦ È£ÃâÇÏ¸é µË´Ï´Ù. URLCache.php ÆÄÀÏÀº »ç¿ëÀÚ°¡ ¿øÇÏ´Â µð·ºÅ丮¿¡ µÎ¸é µË´Ï´Ù. Cache ÇÔ¼öÀÇ Ã¹¹øÂ° ÀÎÀÚ´Â Cache ¿©ºÎÀÌ¸ç µÎ¹øÂ° ÀÎÀÚ´Â Cache µð·ºÅ丮ÀÔ´Ï´Ù. ÇØ´ç µð·ºÅ丮 ¿ª½Ã ¿øÇÏ´Â °÷À¸·Î ¼³Á¤ÇÏ¸é µË´Ï´Ù. ¼Â¹øÂ° ÀÎÀÚ´Â CacheÀÇ lifetime ÀÔ´Ï´Ù.
À§¿Í °°ÀÌ ¼³Á¤ ÈÄ¿¡ ÃÖÃÊ·Î URLÀÌ È£ÃâÀÌ µÇ¸é Cacheµð·ºÅ丮¿¡ ¾Æ·¡¿Í °°ÀÌ CacheµÈ ÆÄÀÏÀÌ ÀúÀåµË´Ï´Ù. ÁÖÀÇ ÇÒ°ÍÀº ÀúÀåÇϱ⠿øÇÏ´Â Cache µð·ºÅ丮´Â ¹Ì¸® »ý¼ºµÇ¾î ÀÖ¾î¾ß ÇÕ´Ï´Ù. ´ç¿¬È÷ ±ÇÇÑÀº À¥»ç¿ëÀÚÀÇ ¾²±â ±ÇÇÑ( chmod 766 ./cache )ÀÌ ÀÖ¾î¾ß ÇÕ´Ï´Ù. »ç¿ëÀÚ°¡ ¼³Á¤ÇÑ lifetime¿¡ µû¶ó¼ ÀÏÁ¤ ½Ã°£ µ¿¾È CacheµÈ ÆÄÀÏÀ» ÅëÇÏ¿© ¼ºñ½º°¡ µÇ¸ç, CacheÆÄÀÏÀº ¼³Á¤µÈ lifetimeÀ» ÁÖ±â·Î °»½ÅµË´Ï´Ù. Cache ÆÄÀϸíÀº È£ÃâµÈ URL¸¦ MD5 ÇÔ¼ö·Î ÀÎÄÚµùÇÑ °ªÀÔ´Ï´Ù.
lsh804:~/www/cache$ ls -al total 12 drwxr-sr-x 2 ihelpers ihelpers 4096 11¢¯u 2 00:17 ./ drwxr-s--x 26 ihelpers ihelpers 4096 11¢¯u 2 00:15 ../ -rw-r--r-- 1 ihelpers ihelpers 2526 11¢¯u 2 00:17 0736bf2173b64ba30a47079fd0670e54
2. URLCache.php Class
URLCache.php ÆÄÀÏÀº URLCache Ŭ·¡½º ¿Í Cache ÇÔ¼ö·Î ÀÌ·ç¾îÁ® ÀÖ½À´Ï´Ù. URLCache Ŭ·¡½º´Â Cache ÆÄÀÏÀÇ »óŸ¦ Á¡°ËÇϰí CacheÆÄÀÏ¿¡ °´Ã¼Á¤º¸¸¦ ¾²°í Àд ¿ªÇÒÀ» ¼öÇàÇÕ´Ï´Ù. Cache ÇÔ¼ö´Â URLCache Ŭ·¡½º¸¦ ±â¹ÝÀ¸·Î Cache ¿©ºÎ¸¦ Á¡°ËÇÏ¿© CacheÀаųª ¾Æ´Ô URL Á¤º¸¸¦ Àоî¿Í Cache ÆÄÀÏ¿¡ ÀúÀåÇÏ´Â ÇÔ¼öÀÔ´Ï´Ù. Cache ÇÔ¼ö´Â ±âÁ¸¿¡ »ç¿ëÇϰí ÀÖ´Â WebApplication ¿¡ Cache ±â¼úÀ» ½±°Ô Àû¿ëÇϱâ À§ÇÑ ÇÔ¼öÀÔ´Ï´Ù.
<? /*/////////////////////////////////////////////////////////////// ÀÛ¼ºÀÚ : ¼Õ»ó¸ð<smson@ihelpers.co.kr> À¥»çÀÌÆ® : http://www.ihelpers.co.kr ÃÖÃÊÀÛ¼ºÀÏ : 2004.10.25 º¯°æ³»¿ë : 2004.11.01 Class¿Ü¿¡ Cache ÇÔ¼ö Ãß°¡ /////////////////////////////////////////////////////////////////*/ /** * URLCache Class * * URL Á¤º¸¸¦ Cache ÇÏ´Â ClassÀÔ´Ï´Ù. * * @author Sang Mo,Son <smson@ihelpers.co.kr> * @version 0.9 beta * @access public */ class URLCache { var $CacheDir; var $Interval; /** * Constructor * * @param String Cache Directory * @param int Url Stale Time(s) * @access public * @return void */ function URLCache($CacheDir = './cache',$Interval = 3600){ $this->CacheDir = $CacheDir; $this->Interval = $Interval; } /** * Set Cache Directory * * @param int Url Stale Time * @access public * @return void */ function setCacheDir($CacheDir){ $this->CacheDir = $CacheDir; } /** * Set Url Stale Time(s) * * @access public * @return void */ function setInterval($Interval){ $this->Interval = $Interval; } /** * URL Á¤º¸¿¡ ÇØ´çÇÏ´Â Á¤º¸¸¦ ÀúÀå * * @param string url * @param object content * @access public * @return void */ function set($url,$obj){ $fname = $this->_makeFileName($url); $fp = fopen($fname,'w'); if($fp){ fwrite($fp,$this->_serialize($obj)); fclose($fp); return true; } else { $this->Error("Unable to open file for writing : $fname"); return false; } } /** * URL Á¤º¸¿¡ ÇØ´çÇÏ´Â Á¤º¸ Àбâ * * @param string url * @access public * @return object */ function get($url){ $fname = $this->_makeFileName($url); $fp = fopen($fname,'r'); if($fp){ $data = fread($fp,filesize($fname)); fclose($fp); return $this->_unserialize($data); } else { $this->Error("Cache doesn't contain : $url"); return false; } } /** * Cache ÆÄÀÏ Á¡°Ë * * @param string url * @access public * @return int( -1 : not found, 0 : Stale, 1 : Hit ) */ function CheckCache($url){ $fname = $this->_makeFileName($url); if(file_exists($fname)){ if((time()- filemtime($fname)) >= $this->Interval){ return 0; } else { return 1; } } else { return -1; } } /** * URL Á¤º¸¸¦ ÆÄÀϸíÀ¸·Î º¯°æ * * @param string url * @access private * @return string */ function _makeFileName($url){ return $this->CacheDir."/".md5($url); } /** * Serialize The Content * * @param object content * @access private * @return string */ function _serialize($object){ return serialize($object); } /** * Unserialize The Content * * @param string content * @access private * @return object */ function _unserialize($content){ return unserialize($content); } /** * Error Á¤º¸ ó¸® * * @param string error message * @access public * @return void */ function Error($errmsg){ printf($errmsg); } } /** * URL Á¤º¸¿¡ ´ëÇÑ Cache ÇÔ¼ö * * @access public * @param boolean isCache * @param string Cache Directory * @param int lifetime * @return boolean */ function Cache($iscache = true,$cachedir = './cache',$lifetime = 3600){ global $HTTP_GET_VARS,$HTTP_POST_VARS,$HTTP_SERVER_VARS; if($iscache == true && $HTTP_GET_VARS['CACHE'] != "NOCACHE" && count($HTTP_POST_VARS) == 0){ $url = sprintf("http://%s%s",$HTTP_SERVER_VARS['HTTP_HOST'],$HTTP_SERVER_VARS['REQUEST_URI']); $urlcache = new URLCache($cachedir,$lifetime); $result = $urlcache->CheckCache($url); if($result == 1){ // lifetime ÀÌÀü $html = $urlcache->get($url); } else { // lfietime ÀÌÈÄ ¶Ç´Â CacheÆÄÀÏÀÌ ¾øÀ» °æ¿ì $curl = sprintf("http://%s%s?CACHE=NOCACHE&%s",$HTTP_SERVER_VARS['HTTP_HOST'], $HTTP_SERVER_VARS['PHP_SELF'],$HTTP_SERVER_VARS['QUERY_STRING']); $fd = fopen ("$curl", "r"); $content = ""; while (!feof ($fd)) { $buffer = fgets($fd, 4096); $content .= $buffer; } $html['body'] = $content; $urlcache->set($url,$html); } echo $html['body']; exit; } else { return false; } } ?>
URLCache Ŭ·¡½º´Â ÀÚ¼¼È÷ »ìÆì º¸¸é Å©°Ô ¾î·Á¿î ºÎºÐÀÌ ¾ø½À´Ï´Ù. CheckCache,set,get Method¸¸ Àß »ì¸éº¸¸é ±× ¿ø¸®¸¦ ½±°Ô ÀÌÇØÇÒ¼ö ÀÖ½À´Ï´Ï´Ù. CheckCache Method´Â À§ÀÇ Äڵ忡¼ º¸´Â °Í ó·³ È£ÃâµÈ URL¸¦ MD5ÇÔ¼ö·Î ÀÎÄÚµùÇÑ ÈÄ¿¡ Cache µð·ºÅ丮¿¡ Cache ÆÄÀÏÀÇ Á¸Àç ¿©ºÎ È®ÀÎÇÏ°í ÆÄÀÏÀÇ ¼öÁ¤µÈ ½Ã°£À» ±â¹ÝÀ¸·Î ¼³Á¤µÈ lifetimeÀÇ ¸¸·á¿©ºÎ¸¦ È®ÀÎ ÇØ ÁÝ´Ï´Ù. set method ´Â object Á¤º¸¸¦ serialize ÇÔ¼ö¸¦ ÀÌ¿ëÇÏ¿© Á÷·ÄÈ ÇÏ¿© Cache ÆÄÀÏ¿¡ ÀúÀåÇϰí get method´Â ¹Ý´ë·Î ÇØ´ç ³»¿ëÀ» Àоî¿É´Ï´Ù.
Cache ÇÔ¼ö´Â URLCache Ŭ·¡½ºÀÇ CheckCache ÇÔ¼ö¸¦ ÅëÇÏ¿© Cache ÆÄÀÏÀÇ »óŸ¦ ±¸ºÐÇÏ¿© lifetime ÀÌÀüÀÎ °æ¿ì´Â CacheÆÄÀÏ¿¡¼ ÀڷḦ Àаí CacheÆÄÀÏÀÌ Á¸ÀçÇÏÁö ¾Ê°Å³ª lifetime º¸´Ù ¿À·¡ µÇ¾úÀ» °æ¿ì´Â CacheÆÄÀÏÀ» »õ·Ó°Ô °»½ÅÇØ ÁÝ´Ï´Ù.
$curl = sprintf("http://%s%s?CACHE=NOCACHE&%s",$HTTP_SERVER_VARS['HTTP_HOST'], $HTTP_SERVER_VARS['PHP_SELF'],$HTTP_SERVER_VARS['QUERY_STRING']);
Parameter °ªÁß¿¡ "CACHE=NOCACHE" ¸¦ Àü´ÞÇÏ¿© ÇØ´ç Page°¡ Cache ±â¼úÀ» »ç¿ëÇÏÁö ¾Ê°í Á÷Á¢ ½ÇÇàµÇµµ·Ï ÇÑ ºÎºÐÀ» ÁÖÀDZí°Ô »ìÆìº¸±â ¹Ù¶ø´Ï´Ù. À߸ø »ç¿ëÇÏ°Ô µÇ¸é ¹«Çѹݺ¹½ÇÇàÀ» ÇÏ°Ô µË´Ï´Ù.
Cache¸¦ »ç¿ëÇÏ¹Ç·Î½á ¸Å¹ø º¹ÀâÇÑ ¿¬»ê°ú DB Á¢¼ÓÀ» ÇØ¾ß ÇÏ´Â ÆäÀÌÁö°¡ Cache µÈ ÆÄÀÏÀ» ¿¢¼¼½º¸¸ ÇÏ¿© ÀúÀåµÈ ³»¿ëÀ» Ãâ·ÂÇØ ÁÖ¹Ç·Î½á ¼¹öÀÇ ºÎÇϸ¦ ÁÙ¿©ÁÖ°í »ç¿ëÀÚ¿¡°Ô ºü¸¥ ·Îµù¼Óµµ¸¦ Á¦°øÇÒ¼ö ÀÖ°Ô µÇ´Â °ÍÀÔ´Ï´Ù. DB¿¡¼ ¸¹Àº ¾çÀÇ ÀڷḦ ½Ç½Ã°£À¸·Î Á¶È¸ÇÏ´Â °ÍÀÌ ¹®Á¦°¡ µÇ¾î ½Ã°£ ¶Ç´Â ÀÏ´ÜÀ§·Î ¹èÄ¡ÀÛ¾÷À» ÇÏ¿© Summary Table¿¡¼ ÀڷḦ Á¶È¸ÇÏ´Â ¹æ¹ý°ú ºñ½ÁÇÏ´Ù°í ÇÒ¼ö ÀÖ°Ú½À´Ï´Ù.
´ÙÀ½Àº À¥»çÀÌÆ® ¼º´É ºÐ¼® ÇÁ·Î±×·¥À» ÀÌ¿ëÇÏ¿© Cache¸¦ »ç¿ëÇÒ¶§¿Í »ç¿ëÇÏÁö ¾ÊÀ» °æ¿ìÀÇ ¼º´É ¹× ¼Óµµ¸¦ ºñ±³ÇÑ °á°úÀÔ´Ï´Ù.
* TPS(Transaction Per Second, Request Per Second), RPS(Response Second)* Å×½ºÆ® Á¶°Ç : Thinking Time - 0.1 ÃÊ, ´ÜÀ§Å×½ºÆ® ½Ã°£ - 1ºÐ
Sample ÄÚµå´Â Cache¸¦ »ç¿ëÇÏ¿´À» °æ¿ì 1.3(21/16)¹èÀÇ ¼º´ÉÇâ»ó º¸¿´À¸¸ç, ´ÜÀÏ Query¿¡¼ ¼Óµµ´Â µÎ¹èÀÌ»ó Çâ»ó µÇ¾ú½À´Ï´Ù. Web ApplicationÀÌ º¹ÀâÇÒ¼ö·Ï Cache¸¦ »ç¿ëÇÏ¹Ç·Î½á ¾òÀ»¼ö ÀÖ´Â È¿°ú´Â Á¡Á¡ Ä¿Áú°ÍÀÔ´Ï´Ù.
Download : URLCache.zip
Yes, it is not the best name for these type of shoes cause you are right, how can one be both barefoot and have shoes on? But really when we say ¡° vibram five fingers kso shoes¡± we mean shoes that embrace the benefits and philosophy of barefoot walking and running.
Some people call these types of shoes minimalist footwear. Some of these so called vibram five fingers kso shoes look even more technical and advanced than regular running shoes. An example ar vibram five fingers kso shoes
Recently,Ugg Boots Clearance more and more people are pay attentions to newest ugg boots,so where to buy Chocolate UGG Classic Tall Boots£¬Pink UGG Classic Tall Boots,Buy MBT Slippers ,Bailey Button Ugg,UGG Classic Mini,especially new ugg boots has become a topic. We all know that ugg boots cheap is extremely comfortable to wear, for they are made from well-selected raw materials.moreover, the newest pop elements would appear in ugg design, this keeps ugg fashionable forever.if you ugg cardy boots are so smart in matching dresses, i assure you will buy ugg boots uk have your personality, since ugg has so many styles to choose.Cheap Ugg Boots are good choices in autumn, with long ones and UGG Classic Argyle Knit ones to choose. and you can match it with your short dress or UGG Nightfall Boots jeans. What¡¯s more,UGG Ultimate Bind can be order from Ugg Cardy Boots online,I should tell you beside many big website,there are also many small website which also supply Women's Sundance Boots ,though there are small,but they can supply all kinds of style and color,what¡¯s more,the price in these website is always the best competitive price.So if you are planing to buy cheap ultra short uggs on sale ,don't forget to buy Cheap Ultra Tall Ugg Boots On Sale .