锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产精品美女久久久久网,久久精品国产一区二区三区不卡,99久久精品费精品国产http://m.shnenglu.com/gordon/榪戝北鍒欏織楂橈紝涓存按鑰岃仾鎱?/description>zh-cnSun, 29 Jun 2025 12:27:15 GMTSun, 29 Jun 2025 12:27:15 GMT60銆愯漿杞姐戜竴鑷存?hash 綆楁硶錛?consistent hashing 錛?/title><link>http://m.shnenglu.com/gordon/archive/2014/06/26/207423.html</link><dc:creator>Gordooooon</dc:creator><author>Gordooooon</author><pubDate>Thu, 26 Jun 2014 10:27:00 GMT</pubDate><guid>http://m.shnenglu.com/gordon/archive/2014/06/26/207423.html</guid><wfw:comment>http://m.shnenglu.com/gordon/comments/207423.html</wfw:comment><comments>http://m.shnenglu.com/gordon/archive/2014/06/26/207423.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.shnenglu.com/gordon/comments/commentRss/207423.html</wfw:commentRss><trackback:ping>http://m.shnenglu.com/gordon/services/trackbacks/207423.html</trackback:ping><description><![CDATA[<div><strong><span style="font-size: 14pt;">杞?/span></strong><a ><strong style="font-size: 14pt;">杞藉湴鍧錛?</strong>http://blog.csdn.net/sparkliang/article/details/5279393</a><br /><br />consistent hashing <span style="font-family: 瀹嬩綋;">綆楁硶鏃╁湪</span> 1997 <span style="font-family: 瀹嬩綋;">騫村氨鍦ㄨ鏂?/span> <strong><a target="_blank" style="color: #336699; text-decoration: none;">Consistent hashing and random trees</a> </strong><span style="font-family: 瀹嬩綋;">涓鎻愬嚭錛岀洰鍓嶅湪</span>cache <span style="font-family: 瀹嬩綋;">緋葷粺涓簲鐢ㄨ秺鏉ヨ秺騫挎硾錛?/span><h2><a name="t1" style="color: rgb(51, 102, 153); text-decoration: none;"></a>1 鍩烘湰鍦烘櫙</h2><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;"><span style="font-family: 瀹嬩綋;">姣斿浣犳湁</span> N <span style="font-family: 瀹嬩綋;">涓?/span> cache <span style="font-family: 瀹嬩綋;">鏈嶅姟鍣紙鍚庨潰綆縐?/span> cache <span style="font-family: 瀹嬩綋;">錛夛紝閭d箞濡備綍灝嗕竴涓璞?/span> object <span style="font-family: 瀹嬩綋;">鏄犲皠鍒?/span> N <span style="font-family: 瀹嬩綋;">涓?/span> cache <span style="font-family: 瀹嬩綋;">涓婂憿錛屼綘寰堝彲鑳戒細閲囩敤綾諱技涓嬮潰鐨勯氱敤鏂規硶璁$畻</span> object <span style="font-family: 瀹嬩綋;">鐨?/span> hash <span style="font-family: 瀹嬩綋;">鍊鹼紝鐒跺悗鍧囧寑鐨勬槧灝勫埌鍒?/span> N <span style="font-family: 瀹嬩綋;">涓?/span> cache <span style="font-family: 瀹嬩綋;">錛?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">hash(object)%N</p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;"><span style="font-family: 瀹嬩綋;">   涓鍒囬兘榪愯姝e父錛屽啀鑰冭檻濡備笅鐨勪袱縐嶆儏鍐碉紱</span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">   1 <span style="font-family: 瀹嬩綋;">涓涓?/span> cache <span style="font-family: 瀹嬩綋;">鏈嶅姟鍣?/span> m down <span style="font-family: 瀹嬩綋;">鎺変簡錛堝湪瀹為檯搴旂敤涓繀欏昏鑰冭檻榪欑鎯呭喌錛夛紝榪欐牱鎵鏈夋槧灝勫埌</span> cache m <span style="font-family: 瀹嬩綋;">鐨勫璞¢兘浼氬け鏁堬紝鎬庝箞鍔烇紝闇瑕佹妸</span> cache m <span style="font-family: 瀹嬩綋;">浠?/span> cache <span style="font-family: 瀹嬩綋;">涓Щ闄わ紝榪欐椂鍊?/span> cache <span style="font-family: 瀹嬩綋;">鏄?/span> N-1 <span style="font-family: 瀹嬩綋;">鍙幫紝鏄犲皠鍏紡鍙樻垚浜?/span> hash(object)%(N-1) <span style="font-family: 瀹嬩綋;">錛?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">   2 <span style="font-family: 瀹嬩綋;">鐢變簬璁塊棶鍔犻噸錛岄渶瑕佹坊鍔?/span> cache <span style="font-family: 瀹嬩綋;">錛岃繖鏃跺?/span> cache <span style="font-family: 瀹嬩綋;">鏄?/span> N+1 <span style="font-family: 瀹嬩綋;">鍙幫紝鏄犲皠鍏紡鍙樻垚浜?/span> hash(object)%(N+1) <span style="font-family: 瀹嬩綋;">錛?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;">1 <span style="font-family: 瀹嬩綋;">鍜?/span> 2 <span style="font-family: 瀹嬩綋;">鎰忓懗鐫浠涔堬紵榪欐剰鍛崇潃紿佺劧涔嬮棿鍑犱箮鎵鏈夌殑</span> cache <span style="font-family: 瀹嬩綋;">閮藉け鏁堜簡銆傚浜庢湇鍔″櫒鑰岃█錛岃繖鏄竴鍦虹伨闅撅紝媧按鑸殑璁塊棶閮戒細鐩存帴鍐插悜鍚庡彴鏈嶅姟鍣紱</span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;"><span style="font-family: 瀹嬩綋;">鍐嶆潵鑰冭檻絎笁涓棶棰橈紝鐢變簬紜歡鑳藉姏瓚婃潵瓚婂己錛屼綘鍙兘鎯寵鍚庨潰娣誨姞鐨勮妭鐐瑰鍋氱偣媧伙紝鏄劇劧涓婇潰鐨?/span> hash <span style="font-family: 瀹嬩綋;">綆楁硶涔熷仛涓嶅埌銆?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">  <span style="font-family: 瀹嬩綋;">鏈変粈涔堟柟娉曞彲浠ユ敼鍙樿繖涓姸鍐靛憿錛岃繖灝辨槸</span> consistent hashing...</p><h2><a name="t2" style="color: rgb(51, 102, 153); text-decoration: none;"></a>2 hash 綆楁硶鍜屽崟璋冩?/h2><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;"><span style="font-family: 瀹嬩綋;">銆銆</span> Hash <span style="font-family: 瀹嬩綋;">綆楁硶鐨勪竴涓 閲忔寚鏍囨槸鍗曡皟鎬э紙</span> Monotonicity <span style="font-family: 瀹嬩綋;">錛夛紝瀹氫箟濡備笅錛?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;"><span style="font-family: 瀹嬩綋;">銆銆鍗曡皟鎬ф槸鎸囧鏋滃凡緇忔湁涓浜涘唴瀹歸氳繃鍝堝笇鍒嗘淳鍒頒簡鐩稿簲鐨勭紦鍐蹭腑錛屽張鏈夋柊鐨勭紦鍐插姞鍏ュ埌緋葷粺涓傚搱甯岀殑緇撴灉搴旇兘澶熶繚璇佸師鏈夊凡鍒嗛厤鐨勫唴瀹瑰彲浠ヨ鏄犲皠鍒版柊鐨勭紦鍐蹭腑鍘伙紝鑰屼笉浼氳鏄犲皠鍒版棫鐨勭紦鍐查泦鍚堜腑鐨勫叾浠栫紦鍐插尯銆?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;"><span style="font-family: 瀹嬩綋;">瀹規槗鐪嬪埌錛屼笂闈㈢殑綆鍗?/span> hash <span style="font-family: 瀹嬩綋;">綆楁硶</span> hash(object)%N <span style="font-family: 瀹嬩綋;">闅句互婊¤凍鍗曡皟鎬ц姹傘?/span></p><h2><a name="t3" style="color: rgb(51, 102, 153); text-decoration: none;"></a>3 consistent hashing 綆楁硶鐨勫師鐞?/h2><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;">consistent hashing <span style="font-family: 瀹嬩綋;">鏄竴縐?/span> hash <span style="font-family: 瀹嬩綋;">綆楁硶錛岀畝鍗曠殑璇達紝鍦ㄧЩ闄?/span> / <span style="font-family: 瀹嬩綋;">娣誨姞涓涓?/span> cache <span style="font-family: 瀹嬩綋;">鏃訛紝瀹冭兘澶熷敖鍙兘灝忕殑鏀瑰彉宸插瓨鍦?/span> key <span style="font-family: 瀹嬩綋;">鏄犲皠鍏崇郴錛屽敖鍙兘鐨勬弧瓚沖崟璋冩х殑瑕佹眰銆?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;"><span style="font-family: 瀹嬩綋;">涓嬮潰灝辨潵鎸夌収</span> 5 <span style="font-family: 瀹嬩綋;">涓楠ょ畝鍗曡璁?/span> consistent hashing <span style="font-family: 瀹嬩綋;">綆楁硶鐨勫熀鏈師鐞嗐?/span></p><h3><a name="t4" style="color: rgb(51, 102, 153); text-decoration: none;"></a>3.1 鐜艦hash 絀洪棿</h3><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;"><span style="font-family: 瀹嬩綋;">鑰冭檻閫氬父鐨?/span> hash <span style="font-family: 瀹嬩綋;">綆楁硶閮芥槸灝?/span> value <span style="font-family: 瀹嬩綋;">鏄犲皠鍒頒竴涓?/span> 32 <span style="font-family: 瀹嬩綋;">涓虹殑</span> key <span style="font-family: 瀹嬩綋;">鍊鹼紝涔熷嵆鏄?/span> 0~2^32-1 <span style="font-family: 瀹嬩綋;">嬈℃柟鐨勬暟鍊肩┖闂達紱鎴戜滑鍙互灝嗚繖涓┖闂存兂璞℃垚涓涓錛?/span> 0 <span style="font-family: 瀹嬩綋;">錛夊熬錛?/span> 2^32-1 <span style="font-family: 瀹嬩綋;">錛夌浉鎺ョ殑鍦嗙幆錛屽涓嬮潰鍥?/span> 1 <span style="font-family: 瀹嬩綋;">鎵紺虹殑閭f牱銆?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" align="center"><img src="http://www.codeproject.com/KB/recipes/lib-conhash/circle.JPG" alt="circle space" style="border: 0pt none; max-width: 100%;" height="104" width="91" /></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" align="center"><span style="font-family: 瀹嬩綋;">鍥?/span> 1 <span style="font-family: 瀹嬩綋;">鐜艦</span> hash <span style="font-family: 瀹嬩綋;">絀洪棿</span></p><h3><a name="t5" style="color: rgb(51, 102, 153); text-decoration: none;"></a>3.2 鎶婂璞℃槧灝勫埌hash 絀洪棿</h3><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;"><span style="font-family: 瀹嬩綋;">鎺ヤ笅鏉ヨ冭檻</span> 4 <span style="font-family: 瀹嬩綋;">涓璞?/span> object1~object4 <span style="font-family: 瀹嬩綋;">錛岄氳繃</span> hash <span style="font-family: 瀹嬩綋;">鍑芥暟璁$畻鍑虹殑</span> hash <span style="font-family: 瀹嬩綋;">鍊?/span> key <span style="font-family: 瀹嬩綋;">鍦ㄧ幆涓婄殑鍒嗗竷濡傚浘</span> 2 <span style="font-family: 瀹嬩綋;">鎵紺恒?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">hash(object1) = key1;</p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">… …</p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">hash(object4) = key4;</p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" align="center"><img src="http://www.codeproject.com/KB/recipes/lib-conhash/object.JPG" alt="object" style="border: 0pt none; max-width: 100%;" height="253" width="234" /></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" align="center"><span style="font-family: 瀹嬩綋;">鍥?/span> 2 4 <span style="font-family: 瀹嬩綋;">涓璞$殑</span> key <span style="font-family: 瀹嬩綋;">鍊煎垎甯?/span></p><h3><a name="t6" style="color: rgb(51, 102, 153); text-decoration: none;"></a>3.3 鎶奵ache 鏄犲皠鍒癶ash 絀洪棿</h3><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;">Consistent hashing <span style="font-family: 瀹嬩綋;">鐨勫熀鏈濇兂灝辨槸灝嗗璞″拰</span> cache <span style="font-family: 瀹嬩綋;">閮芥槧灝勫埌鍚屼竴涓?/span> hash <span style="font-family: 瀹嬩綋;">鏁板肩┖闂翠腑錛屽茍涓斾嬌鐢ㄧ浉鍚岀殑</span> hash<span style="font-family: 瀹嬩綋;">綆楁硶銆?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;"><span style="font-family: 瀹嬩綋;">鍋囪褰撳墠鏈?/span> A,B <span style="font-family: 瀹嬩綋;">鍜?/span> C <span style="font-family: 瀹嬩綋;">鍏?/span> 3 <span style="font-family: 瀹嬩綋;">鍙?/span> cache <span style="font-family: 瀹嬩綋;">錛岄偅涔堝叾鏄犲皠緇撴灉灝嗗鍥?/span> 3 <span style="font-family: 瀹嬩綋;">鎵紺猴紝浠栦滑鍦?/span> hash <span style="font-family: 瀹嬩綋;">絀洪棿涓紝浠ュ搴旂殑</span> hash <span style="font-family: 瀹嬩綋;">鍊兼帓鍒椼?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">hash(cache A) = key A;</p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">… …</p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">hash(cache C) = key C;</p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" align="center"><img src="http://www.codeproject.com/KB/recipes/lib-conhash/cache.JPG" alt="cache" style="border: 0pt none; max-width: 100%;" height="253" width="283" /></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" align="center"><span style="font-family: 瀹嬩綋;">鍥?/span> 3 cache <span style="font-family: 瀹嬩綋;">鍜屽璞$殑</span> key <span style="font-family: 瀹嬩綋;">鍊煎垎甯?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" align="center"> </p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;"><span style="font-family: 瀹嬩綋;">璇村埌榪欓噷錛岄『渚挎彁涓涓?/span> cache <span style="font-family: 瀹嬩綋;">鐨?/span> hash <span style="font-family: 瀹嬩綋;">璁$畻錛屼竴鑸殑鏂規硶鍙互浣跨敤</span> cache <span style="font-family: 瀹嬩綋;">鏈哄櫒鐨?/span> IP <span style="font-family: 瀹嬩綋;">鍦板潃鎴栬呮満鍣ㄥ悕浣滀負</span> hash<span style="font-family: 瀹嬩綋;">杈撳叆銆?/span></p><h3><a name="t7" style="color: rgb(51, 102, 153); text-decoration: none;"></a>3.4 鎶婂璞℃槧灝勫埌cache</h3><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;"><span style="font-family: 瀹嬩綋;">鐜板湪</span> cache <span style="font-family: 瀹嬩綋;">鍜屽璞¢兘宸茬粡閫氳繃鍚屼竴涓?/span> hash <span style="font-family: 瀹嬩綋;">綆楁硶鏄犲皠鍒?/span> hash <span style="font-family: 瀹嬩綋;">鏁板肩┖闂翠腑浜嗭紝鎺ヤ笅鏉ヨ鑰冭檻鐨勫氨鏄浣曞皢瀵硅薄鏄犲皠鍒?/span> cache <span style="font-family: 瀹嬩綋;">涓婇潰浜嗐?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;"><span style="font-family: 瀹嬩綋;">鍦ㄨ繖涓幆褰㈢┖闂翠腑錛屽鏋滄部鐫欏烘椂閽堟柟鍚戜粠瀵硅薄鐨?/span> key <span style="font-family: 瀹嬩綋;">鍊煎嚭鍙戯紝鐩村埌閬囪涓涓?/span> cache <span style="font-family: 瀹嬩綋;">錛岄偅涔堝氨灝嗚瀵硅薄瀛樺偍鍦ㄨ繖涓?/span> cache <span style="font-family: 瀹嬩綋;">涓婏紝鍥犱負瀵硅薄鍜?/span> cache <span style="font-family: 瀹嬩綋;">鐨?/span> hash <span style="font-family: 瀹嬩綋;">鍊兼槸鍥哄畾鐨勶紝鍥犳榪欎釜</span> cache <span style="font-family: 瀹嬩綋;">蹇呯劧鏄敮涓鍜岀‘瀹氱殑銆傝繖鏍蜂笉灝辨壘鍒頒簡瀵硅薄鍜?/span> cache <span style="font-family: 瀹嬩綋;">鐨勬槧灝勬柟娉曚簡鍚楋紵錛?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;"><span style="font-family: 瀹嬩綋;">渚濈劧緇х畫涓婇潰鐨勪緥瀛愶紙鍙傝鍥?/span> 3 <span style="font-family: 瀹嬩綋;">錛夛紝閭d箞鏍規嵁涓婇潰鐨勬柟娉曪紝瀵硅薄</span> object1 <span style="font-family: 瀹嬩綋;">灝嗚瀛樺偍鍒?/span> cache A <span style="font-family: 瀹嬩綋;">涓婏紱</span> object2 <span style="font-family: 瀹嬩綋;">鍜?/span>object3 <span style="font-family: 瀹嬩綋;">瀵瑰簲鍒?/span> cache C <span style="font-family: 瀹嬩綋;">錛?/span> object4 <span style="font-family: 瀹嬩綋;">瀵瑰簲鍒?/span> cache B <span style="font-family: 瀹嬩綋;">錛?/span></p><h3><a name="t8" style="color: rgb(51, 102, 153); text-decoration: none;"></a>3.5 鑰冨療cache 鐨勫彉鍔?/h3><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;"><span style="font-family: 瀹嬩綋;">鍓嶉潰璁茶繃錛岄氳繃</span> hash <span style="font-family: 瀹嬩綋;">鐒跺悗姹備綑鐨勬柟娉曞甫鏉ョ殑鏈澶ч棶棰樺氨鍦ㄤ簬涓嶈兘婊¤凍鍗曡皟鎬э紝褰?/span> cache <span style="font-family: 瀹嬩綋;">鏈夋墍鍙樺姩鏃訛紝</span> cache<span style="font-family: 瀹嬩綋;">浼氬け鏁堬紝榪涜屽鍚庡彴鏈嶅姟鍣ㄩ犳垚宸ㄥぇ鐨勫啿鍑伙紝鐜板湪灝辨潵鍒嗘瀽鍒嗘瀽</span> consistent hashing <span style="font-family: 瀹嬩綋;">綆楁硶銆?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;"><strong>3.5.1 </strong><strong><span style="font-family: 瀹嬩綋;">縐婚櫎</span> cache</strong></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;"><span style="font-family: 瀹嬩綋;">鑰冭檻鍋囪</span> cache B <span style="font-family: 瀹嬩綋;">鎸傛帀浜嗭紝鏍規嵁涓婇潰璁插埌鐨勬槧灝勬柟娉曪紝榪欐椂鍙楀獎鍝嶇殑灝嗕粎鏄偅浜涙部</span> cache B <span style="font-family: 瀹嬩綋;">閫嗘椂閽堥亶鍘嗙洿鍒頒笅涓涓?/span> cache <span style="font-family: 瀹嬩綋;">錛?/span> cache C <span style="font-family: 瀹嬩綋;">錛変箣闂寸殑瀵硅薄錛屼篃鍗蟲槸鏈潵鏄犲皠鍒?/span> cache B <span style="font-family: 瀹嬩綋;">涓婄殑閭d簺瀵硅薄銆?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;"><span style="font-family: 瀹嬩綋;">鍥犳榪欓噷浠呴渶瑕佸彉鍔ㄥ璞?/span> object4 <span style="font-family: 瀹嬩綋;">錛屽皢鍏墮噸鏂版槧灝勫埌</span> cache C <span style="font-family: 瀹嬩綋;">涓婂嵆鍙紱鍙傝鍥?/span> 4 <span style="font-family: 瀹嬩綋;">銆?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" align="center"><img src="http://www.codeproject.com/KB/recipes/lib-conhash/remove.JPG" alt="remove" style="border: 0pt none; max-width: 100%;" height="253" width="283" /></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" align="center"><span style="font-family: 瀹嬩綋;">鍥?/span> 4 Cache B <span style="font-family: 瀹嬩綋;">琚Щ闄ゅ悗鐨?/span> cache <span style="font-family: 瀹嬩綋;">鏄犲皠</span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;"><strong>3.5.2 </strong><strong><span style="font-family: 瀹嬩綋;">娣誨姞</span> cache</strong></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;"><span style="font-family: 瀹嬩綋;">鍐嶈冭檻娣誨姞涓鍙版柊鐨?/span> cache D <span style="font-family: 瀹嬩綋;">鐨勬儏鍐碉紝鍋囪鍦ㄨ繖涓幆褰?/span> hash <span style="font-family: 瀹嬩綋;">絀洪棿涓紝</span> cache D <span style="font-family: 瀹嬩綋;">琚槧灝勫湪瀵硅薄</span> object2 <span style="font-family: 瀹嬩綋;">鍜?/span>object3 <span style="font-family: 瀹嬩綋;">涔嬮棿銆傝繖鏃跺彈褰卞搷鐨勫皢浠呮槸閭d簺娌?/span> cache D <span style="font-family: 瀹嬩綋;">閫嗘椂閽堥亶鍘嗙洿鍒頒笅涓涓?/span> cache <span style="font-family: 瀹嬩綋;">錛?/span> cache B <span style="font-family: 瀹嬩綋;">錛変箣闂寸殑瀵硅薄錛堝畠浠槸涔熸湰鏉ユ槧灝勫埌</span> cache C <span style="font-family: 瀹嬩綋;">涓婂璞$殑涓閮ㄥ垎錛夛紝灝嗚繖浜涘璞¢噸鏂版槧灝勫埌</span> cache D <span style="font-family: 瀹嬩綋;">涓婂嵆鍙?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;"> </p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;"><span style="font-family: 瀹嬩綋;">鍥犳榪欓噷浠呴渶瑕佸彉鍔ㄥ璞?/span> object2 <span style="font-family: 瀹嬩綋;">錛屽皢鍏墮噸鏂版槧灝勫埌</span> cache D <span style="font-family: 瀹嬩綋;">涓婏紱鍙傝鍥?/span> 5 <span style="font-family: 瀹嬩綋;">銆?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" align="center"><img src="http://www.codeproject.com/KB/recipes/lib-conhash/add.JPG" alt="add" style="border: 0pt none; max-width: 100%;" height="253" width="283" /></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" align="center"><span style="font-family: 瀹嬩綋;">鍥?/span> 5 <span style="font-family: 瀹嬩綋;">娣誨姞</span> cache D <span style="font-family: 瀹嬩綋;">鍚庣殑鏄犲皠鍏崇郴</span></p><h2><a name="t9" style="color: rgb(51, 102, 153); text-decoration: none;"></a>4 铏氭嫙鑺傜偣</h2><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;"><span style="font-family: 瀹嬩綋;">鑰冮噺</span> Hash <span style="font-family: 瀹嬩綋;">綆楁硶鐨勫彟涓涓寚鏍囨槸騫寵 鎬?/span> (Balance) <span style="font-family: 瀹嬩綋;">錛屽畾涔夊涓嬶細</span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;"><span style="font-family: 瀹嬩綋;">騫寵 鎬?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;"><span style="font-family: 瀹嬩綋;">銆銆騫寵 鎬ф槸鎸囧搱甯岀殑緇撴灉鑳藉灝藉彲鑳藉垎甯冨埌鎵鏈夌殑緙撳啿涓幓錛岃繖鏍峰彲浠ヤ嬌寰楁墍鏈夌殑緙撳啿絀洪棿閮藉緱鍒板埄鐢ㄣ?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">hash <span style="font-family: 瀹嬩綋;">綆楁硶騫朵笉鏄繚璇佺粷瀵圭殑騫寵 錛屽鏋?/span> cache <span style="font-family: 瀹嬩綋;">杈冨皯鐨勮瘽錛屽璞″茍涓嶈兘琚潎鍖鐨勬槧灝勫埌</span> cache <span style="font-family: 瀹嬩綋;">涓婏紝姣斿鍦ㄤ笂闈㈢殑渚嬪瓙涓紝浠呴儴緗?/span> cache A <span style="font-family: 瀹嬩綋;">鍜?/span> cache C <span style="font-family: 瀹嬩綋;">鐨勬儏鍐典笅錛屽湪</span> 4 <span style="font-family: 瀹嬩綋;">涓璞′腑錛?/span> cache A <span style="font-family: 瀹嬩綋;">浠呭瓨鍌ㄤ簡</span> object1 <span style="font-family: 瀹嬩綋;">錛岃?/span> cache C <span style="font-family: 瀹嬩綋;">鍒欏瓨鍌ㄤ簡</span>object2 <span style="font-family: 瀹嬩綋;">銆?/span> object3 <span style="font-family: 瀹嬩綋;">鍜?/span> object4 <span style="font-family: 瀹嬩綋;">錛涘垎甯冩槸寰堜笉鍧囪 鐨勩?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;"><span style="font-family: 瀹嬩綋;">涓轟簡瑙e喅榪欑鎯呭喌錛?/span> consistent hashing <span style="font-family: 瀹嬩綋;">寮曞叆浜?#8220;铏氭嫙鑺傜偣”鐨勬蹇碉紝瀹冨彲浠ュ涓嬪畾涔夛細</span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;"><span style="font-family: 瀹嬩綋;">“铏氭嫙鑺傜偣”錛?/span> virtual node <span style="font-family: 瀹嬩綋;">錛夋槸瀹為檯鑺傜偣鍦?/span> hash <span style="font-family: 瀹嬩綋;">絀洪棿鐨勫鍒跺搧錛?/span> replica <span style="font-family: 瀹嬩綋;">錛夛紝涓瀹為檯涓妭鐐瑰搴斾簡鑻ュ共涓?#8220;铏氭嫙鑺傜偣”錛岃繖涓搴斾釜鏁頒篃鎴愪負“澶嶅埗涓暟”錛?#8220;铏氭嫙鑺傜偣”鍦?/span> hash <span style="font-family: 瀹嬩綋;">絀洪棿涓互</span> hash <span style="font-family: 瀹嬩綋;">鍊兼帓鍒椼?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;"><span style="font-family: 瀹嬩綋;">浠嶄互浠呴儴緗?/span> cache A <span style="font-family: 瀹嬩綋;">鍜?/span> cache C <span style="font-family: 瀹嬩綋;">鐨勬儏鍐典負渚嬶紝鍦ㄥ浘</span> 4 <span style="font-family: 瀹嬩綋;">涓垜浠凡緇忕湅鍒幫紝</span> cache <span style="font-family: 瀹嬩綋;">鍒嗗竷騫朵笉鍧囧寑銆傜幇鍦ㄦ垜浠紩鍏ヨ櫄鎷熻妭鐐癸紝騫惰緗?#8220;澶嶅埗涓暟”涓?/span> 2 <span style="font-family: 瀹嬩綋;">錛岃繖灝辨剰鍛崇潃涓鍏變細瀛樺湪</span> 4 <span style="font-family: 瀹嬩綋;">涓?#8220;铏氭嫙鑺傜偣”錛?/span> cache A1, cache A2 <span style="font-family: 瀹嬩綋;">浠h〃浜?/span>cache A <span style="font-family: 瀹嬩綋;">錛?/span> cache C1, cache C2 <span style="font-family: 瀹嬩綋;">浠h〃浜?/span> cache C <span style="font-family: 瀹嬩綋;">錛涘亣璁句竴縐嶆瘮杈冪悊鎯崇殑鎯呭喌錛屽弬瑙佸浘</span> 6 <span style="font-family: 瀹嬩綋;">銆?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" align="center"><img src="http://www.codeproject.com/KB/recipes/lib-conhash/virtual.JPG" alt="virtual nodes" style="border: 0pt none; max-width: 100%;" height="253" width="283" /></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" align="center"><span style="font-family: 瀹嬩綋;">鍥?/span> 6 <span style="font-family: 瀹嬩綋;">寮曞叆“铏氭嫙鑺傜偣”鍚庣殑鏄犲皠鍏崇郴</span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" align="center"> </p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;"><span style="font-family: 瀹嬩綋;">姝ゆ椂錛屽璞″埌“铏氭嫙鑺傜偣”鐨勬槧灝勫叧緋諱負錛?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">objec1->cache A2 <span style="font-family: 瀹嬩綋;">錛?/span> objec2->cache A1 <span style="font-family: 瀹嬩綋;">錛?/span> objec3->cache C1 <span style="font-family: 瀹嬩綋;">錛?/span> objec4->cache C2 <span style="font-family: 瀹嬩綋;">錛?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;"><span style="font-family: 瀹嬩綋;">鍥犳瀵硅薄</span> object1 <span style="font-family: 瀹嬩綋;">鍜?/span> object2 <span style="font-family: 瀹嬩綋;">閮借鏄犲皠鍒頒簡</span> cache A <span style="font-family: 瀹嬩綋;">涓婏紝鑰?/span> object3 <span style="font-family: 瀹嬩綋;">鍜?/span> object4 <span style="font-family: 瀹嬩綋;">鏄犲皠鍒頒簡</span> cache C <span style="font-family: 瀹嬩綋;">涓婏紱騫寵 鎬ф湁浜嗗緢澶ф彁楂樸?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;"><span style="font-family: 瀹嬩綋;">寮曞叆“铏氭嫙鑺傜偣”鍚庯紝鏄犲皠鍏崇郴灝變粠</span> { <span style="font-family: 瀹嬩綋;">瀵硅薄</span> -> <span style="font-family: 瀹嬩綋;">鑺傜偣</span> } <span style="font-family: 瀹嬩綋;">杞崲鍒頒簡</span> { <span style="font-family: 瀹嬩綋;">瀵硅薄</span> -> <span style="font-family: 瀹嬩綋;">铏氭嫙鑺傜偣</span> } <span style="font-family: 瀹嬩綋;">銆傛煡璇㈢墿浣撴墍鍦?/span> cache <span style="font-family: 瀹嬩綋;">鏃剁殑鏄犲皠鍏崇郴濡傚浘</span> 7 <span style="font-family: 瀹嬩綋;">鎵紺恒?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" align="center"><img src="http://www.codeproject.com/KB/recipes/lib-conhash/map.JPG" alt="map" style="border: 0pt none; max-width: 100%;" height="232" width="529" /></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" align="center"><span style="font-family: 瀹嬩綋;">鍥?/span> 7 <span style="font-family: 瀹嬩綋;">鏌ヨ瀵硅薄鎵鍦?/span> cache</p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" align="center"> </p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;"><span style="font-family: 瀹嬩綋;">“铏氭嫙鑺傜偣”鐨?/span> hash <span style="font-family: 瀹嬩綋;">璁$畻鍙互閲囩敤瀵瑰簲鑺傜偣鐨?/span> IP <span style="font-family: 瀹嬩綋;">鍦板潃鍔犳暟瀛楀悗緙鐨勬柟寮忋備緥濡傚亣璁?/span> cache A <span style="font-family: 瀹嬩綋;">鐨?/span> IP <span style="font-family: 瀹嬩綋;">鍦板潃涓?/span>202.168.14.241 <span style="font-family: 瀹嬩綋;">銆?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;"><span style="font-family: 瀹嬩綋;">寮曞叆“铏氭嫙鑺傜偣”鍓嶏紝璁$畻</span> cache A <span style="font-family: 瀹嬩綋;">鐨?/span> hash <span style="font-family: 瀹嬩綋;">鍊鹼細</span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">Hash(“202.168.14.241”);</p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;"><span style="font-family: 瀹嬩綋;">寮曞叆“铏氭嫙鑺傜偣”鍚庯紝璁$畻“铏氭嫙鑺?#8221;鐐?/span> cache A1 <span style="font-family: 瀹嬩綋;">鍜?/span> cache A2 <span style="font-family: 瀹嬩綋;">鐨?/span> hash <span style="font-family: 瀹嬩綋;">鍊鹼細</span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">Hash(“202.168.14.241#1”);<span>  // cache A1</span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">Hash(“202.168.14.241#2”);<span>  // cache A2</span></p><h2><a name="t10" style="color: rgb(51, 102, 153); text-decoration: none;"></a>5 灝忕粨</h2><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;">Consistent hashing <span style="font-family: 瀹嬩綋;">鐨勫熀鏈師鐞嗗氨鏄繖浜涳紝鍏蜂綋鐨勫垎甯冩х瓑鐞嗚鍒嗘瀽搴旇鏄緢澶嶆潅鐨勶紝涓嶈繃涓鑸篃鐢ㄤ笉鍒般?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;"><a style="color: #336699; text-decoration: none;">http://weblogs.java.net/blog/2007/11/27/consistent-hashing</a> <span style="font-family: 瀹嬩綋;">涓婇潰鏈変竴涓?/span> java <span style="font-family: 瀹嬩綋;">鐗堟湰鐨勪緥瀛愶紝鍙互鍙傝冦?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;"><a style="color: #336699; text-decoration: none;">http://blog.csdn.net/mayongzhan/archive/2009/06/25/4298834.aspx</a> <span style="font-family: 瀹嬩綋;">杞澆浜嗕竴涓?/span> PHP <span style="font-family: 瀹嬩綋;">鐗堢殑瀹炵幇浠g爜銆?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;"><span style="font-family: 瀹嬩綋;"><a style="color: #336699; text-decoration: none;">http://www.codeproject.com/KB/recipes/lib-conhash.aspx</a> C璇█鐗堟湰<br /></span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-indent: 21pt;"><span style="font-family: 瀹嬩綋;"><br /></span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;"> </p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;"><span style="font-family: 瀹嬩綋;">涓浜涘弬鑰冭祫鏂欏湴鍧錛?/span></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;"><a target="_blank" style="color: #336699; text-decoration: none;">http://portal.acm.org/citation.cfm?id=258660</a></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;"><a target="_blank" style="color: #336699; text-decoration: none;">http://en.wikipedia.org/wiki/Consistent_hashing</a></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;"><a target="_blank" style="color: #336699; text-decoration: none;">http://www.spiteful.com/2008/03/17/programmers-toolbox-part-3-consistent-hashing/</a></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;"> <a style="color: #336699; text-decoration: none;">http://weblogs.java.net/blog/2007/11/27/consistent-hashing</a></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;"><a style="color: #336699; text-decoration: none;">http://tech.idv2.com/2008/07/24/memcached-004/</a></p><p style="color: #333333; font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;"><a style="color: #336699; text-decoration: none;">http://blog.csdn.net/mayongzhan/archive/2009/06/25/4298834.aspx</a></p></div><img src ="http://m.shnenglu.com/gordon/aggbug/207423.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.shnenglu.com/gordon/" target="_blank">Gordooooon</a> 2014-06-26 18:27 <a href="http://m.shnenglu.com/gordon/archive/2014/06/26/207423.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>銆愯漿杞姐慓oogle Protocol Buffer 鐨勪嬌鐢ㄥ拰鍘熺悊http://m.shnenglu.com/gordon/archive/2014/06/19/207339.htmlGordooooonGordooooonThu, 19 Jun 2014 10:06:00 GMThttp://m.shnenglu.com/gordon/archive/2014/06/19/207339.htmlhttp://m.shnenglu.com/gordon/comments/207339.htmlhttp://m.shnenglu.com/gordon/archive/2014/06/19/207339.html#Feedback0http://m.shnenglu.com/gordon/comments/commentRss/207339.htmlhttp://m.shnenglu.com/gordon/services/trackbacks/207339.html闃呰鍏ㄦ枃

]]>
C++鍏抽敭瀛?/title><link>http://m.shnenglu.com/gordon/archive/2012/05/22/175763.html</link><dc:creator>Gordooooon</dc:creator><author>Gordooooon</author><pubDate>Tue, 22 May 2012 07:16:00 GMT</pubDate><guid>http://m.shnenglu.com/gordon/archive/2012/05/22/175763.html</guid><wfw:comment>http://m.shnenglu.com/gordon/comments/175763.html</wfw:comment><comments>http://m.shnenglu.com/gordon/archive/2012/05/22/175763.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://m.shnenglu.com/gordon/comments/commentRss/175763.html</wfw:commentRss><trackback:ping>http://m.shnenglu.com/gordon/services/trackbacks/175763.html</trackback:ping><description><![CDATA[闈㈣瘯榪囩▼涓紝涓浜涢潰璇曞畼瀵笴++涓浜涚壒孌婂叧閿瓧寰堝叧娉紱<br />鏁寸悊浜嗕竴浜涙瘮杈冩湁璇村ご鐨勫叧閿瓧<br /><ul><li>explicit</li></ul>鐢ㄦ潵澹版槑鏋勯犲嚱鏁幫紝琚0鏄庣殑鏋勯犲嚱鏁頒負鏄劇ず鏋勯犲嚱鏁幫紝涓嶈兘鍦ㄩ殣寮忚漿鎹腑浣跨敤銆?br />C++涓竴涓弬鏁扮殑鏋勯犲嚱鏁版垨闄ょ涓涓弬鏁板鍧囨湁榛樿鍊肩殑澶氬弬鏋勯犲嚱鏁幫紝鏈変袱涓綔鐢細1銆佹瀯閫犲璞★紱2銆侀粯璁や笖闅愬紡鐨勭被鍨嬭漿鎹㈡搷浣滅銆?font class="Apple-style-span" face="arial, 瀹嬩綋, sans-serif"><span id="kayoaci" class="Apple-style-span" style="line-height: 24px; "><br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><span style="color: #008080; "> 1</span> <span style="color: #0000FF; ">class</span><span style="color: #000000; "> foo<br /></span><span style="color: #008080; "> 2</span> <span style="color: #000000; ">{<br /></span><span style="color: #008080; "> 3</span> <span style="color: #000000; "></span><span style="color: #0000FF; ">public</span><span style="color: #000000; ">:<br /></span><span style="color: #008080; "> 4</span> <span style="color: #000000; ">    </span><span style="color: #0000FF; ">explicit</span><span style="color: #000000; "> foo( </span><span style="color: #0000FF; ">int</span><span style="color: #000000; "> a )<br /></span><span style="color: #008080; "> 5</span> <span style="color: #000000; ">        : _member( a )<br /></span><span style="color: #008080; "> 6</span> <span style="color: #000000; ">    {}<br /></span><span style="color: #008080; "> 7</span> <span style="color: #000000; "><br /></span><span style="color: #008080; "> 8</span> <span style="color: #000000; ">    </span><span style="color: #0000FF; ">int</span><span style="color: #000000; "> _member;<br /></span><span style="color: #008080; "> 9</span> <span style="color: #000000; ">};<br /></span><span style="color: #008080; ">10</span> <span style="color: #000000; "><br /></span><span style="color: #008080; ">11</span> <span style="color: #000000; "></span><span style="color: #0000FF; ">int</span><span style="color: #000000; "> bar( </span><span style="color: #0000FF; ">const</span><span style="color: #000000; "> foo </span><span style="color: #000000; ">&</span><span style="color: #000000; "> f )<br /></span><span style="color: #008080; ">12</span> <span style="color: #000000; ">{<br /></span><span style="color: #008080; ">13</span> <span style="color: #000000; ">    </span><span style="color: #0000FF; ">return</span><span style="color: #000000; "> f._member;<br /></span><span style="color: #008080; ">14</span> <span style="color: #000000; ">}<br /></span><span style="color: #008080; ">15</span> <span style="color: #000000; "><br /></span><span style="color: #008080; ">16</span> <span style="color: #000000; ">bar( </span><span style="color: #000000; ">1</span><span style="color: #000000; "> ); </span><span style="color: #008000; ">//</span><span style="color: #008000; "> 澶辮觸, explicit紱佹int鍒癴oo鐨勯殣寮?implicit)綾誨瀷杞崲.</span><span style="color: #008000; "><br /></span><span style="color: #008080; ">17</span> <span style="color: #008000; "></span><span style="color: #000000; "><br /></span><span style="color: #008080; ">18</span> <span style="color: #000000; ">bar( foo( </span><span style="color: #000000; ">1</span><span style="color: #000000; "> ) ); </span><span style="color: #008000; ">//</span><span style="color: #008000; "> 姝g‘, 鏄懼紡璋冪敤explicit鏋勯犲嚱鏁?</span><span style="color: #008000; "><br /></span><span style="color: #008080; ">19</span> <span style="color: #008000; "></span><span style="color: #000000; "><br /></span><span style="color: #008080; ">20</span> <span style="color: #000000; ">bar( static_cast</span><span style="color: #000000; "><</span><span style="color: #000000; ">foo</span><span style="color: #000000; ">></span><span style="color: #000000; ">( </span><span style="color: #000000; ">1</span><span style="color: #000000; "> ) );  </span><span style="color: #008000; ">//</span><span style="color: #008000; "> 姝g‘, 閫氳繃static_cast璋冪敤explicit鏋勯犲嚱鏁?</span><span style="color: #008000; "><br /></span><span style="color: #008080; ">21</span> <span style="color: #008000; "></span><span style="color: #000000; "><br /></span><span style="color: #008080; ">22</span> <span style="color: #000000; ">bar( foo( </span><span style="color: #000000; ">1.0</span><span style="color: #000000; "> ) );  </span><span style="color: #008000; ">//</span><span style="color: #008000; "> 姝g‘, 鏄懼紡璋冪敤explicit鏋勯犲嚱鏁? 鍙傛暟鑷姩浠庢誕鐐硅漿鎹㈡垚鏁村瀷.</span></div><br /><ul><li>mutable</li></ul></span></font><font class="Apple-style-span" face="arial, 瀹嬩綋, sans-serif"><span id="wmuycuu" class="Apple-style-span" style="line-height: 24px; ">鐢ㄦ潵澹版槑涓涓垚鍛樺彉閲忥紝琚玬utable澹版槑鐨勬垚鍛樺彉閲忥紝鍙互鍦ㄨconst淇グ鐨勬垚鍛樺嚱鏁頒腑淇敼銆?br /></span></font><font class="Apple-style-span" face="arial, 瀹嬩綋, sans-serif"><span id="kismkis" class="Apple-style-span" style="line-height: 24px; ">mutable涓嶅彲涓巆onst銆乻tatic鍚屾椂浣跨敤銆?/span></font><font class="Apple-style-span" face="arial, 瀹嬩綋, sans-serif"><span id="wegeqow" class="Apple-style-span" style="line-height: 24px; "><br /><div style="font-size: 13px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-right: 5px; padding-bottom: 4px; padding-left: 4px; padding-top: 4px; width: 98%; word-break: break-all; background-color: #eeeeee; "><span style="color: #008080; "> 1</span> <span style="color: #0000FF; ">class</span><span style="color: #000000; "> foo<br /></span><span style="color: #008080; "> 2</span> <span style="color: #000000; ">{<br /></span><span style="color: #008080; "> 3</span> <span style="color: #000000; "></span><span style="color: #0000FF; ">public</span><span style="color: #000000; ">:<br /></span><span style="color: #008080; "> 4</span> <span style="color: #000000; ">    foo()<br /></span><span style="color: #008080; "> 5</span> <span style="color: #000000; ">        : _member(</span><span style="color: #000000; ">0</span><span style="color: #000000; ">)<br /></span><span style="color: #008080; "> 6</span> <span style="color: #000000; ">    {}<br /></span><span style="color: #008080; "> 7</span> <span style="color: #000000; "><br /></span><span style="color: #008080; "> 8</span> <span style="color: #000000; ">    </span><span style="color: #0000FF; ">void</span><span style="color: #000000; "> ExChange( </span><span style="color: #0000FF; ">int</span><span style="color: #000000; "> a ) </span><span style="color: #0000FF; ">const</span><span style="color: #000000; "><br /></span><span style="color: #008080; "> 9</span> <span style="color: #000000; ">    {<br /></span><span style="color: #008080; ">10</span> <span style="color: #000000; ">        _member </span><span style="color: #000000; ">=</span><span style="color: #000000; "> a;<br /></span><span style="color: #008080; ">11</span> <span style="color: #000000; ">    }<br /></span><span style="color: #008080; ">12</span> <span style="color: #000000; "><br /></span><span style="color: #008080; ">13</span> <span style="color: #000000; ">    mutable </span><span style="color: #0000FF; ">int</span><span style="color: #000000; "> _member;<br /></span><span style="color: #008080; ">14</span> <span style="color: #000000; ">}</span></div><br /><div><ul><li>volatile</li></ul></div></span></font><font class="Apple-style-span" face="arial, 瀹嬩綋, sans-serif"><span id="caceqeu" class="Apple-style-span" style="line-height: 24px; "><div>鐢ㄤ互澹版槑涓涓彉閲忥紝琚玽olatile澹版槑鐨勫彉閲忔剰鍛崇潃鏈夊彲鑳借鏌愪簺緙栬瘧鍣ㄦ湭鐭ョ殑鍥犵礌鏇存敼錛屽洜姝ょ紪璇戝櫒涓嶄細瀵瑰叾鍋氫換浣曚紭鍖栨搷浣溿?/div></span></font><font class="Apple-style-span" face="arial, 瀹嬩綋, sans-serif"><span id="uamoigu" class="Apple-style-span" style="line-height: 24px; "><div><div>浠庤屽彲浠ユ彁渚涘鐗規畩鍦板潃鐨勭ǔ瀹氳闂紝澶氱敤浜庡祵鍏ュ紡緙栫▼涓?/div></div></span></font><font class="Apple-style-span" face="arial, 瀹嬩綋, sans-serif"><span id="igsueua" class="Apple-style-span" style="line-height: 24px; "><div><div><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><span style="color: #008080; "> 1</span> <span style="color: #0000FF; ">void</span><span style="color: #000000; "> foo()<br /></span><span style="color: #008080; "> 2</span> <span style="color: #000000; ">{<br /></span><span style="color: #008080; "> 3</span> <span style="color: #000000; ">    </span><span style="color: #008000; ">//</span><span style="color: #008000; ">volatile int nData = 1;</span><span style="color: #008000; "><br /></span><span style="color: #008080; "> 4</span> <span style="color: #008000; "></span><span style="color: #000000; ">    </span><span style="color: #0000FF; ">int</span><span style="color: #000000; "> nData </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #000000; ">1</span><span style="color: #000000; ">;<br /></span><span style="color: #008080; "> 5</span> <span style="color: #000000; "><br /></span><span style="color: #008080; "> 6</span> <span style="color: #000000; ">    </span><span style="color: #0000FF; ">int</span><span style="color: #000000; "> nData_b </span><span style="color: #000000; ">=</span><span style="color: #000000; "> nData;<br /></span><span style="color: #008080; "> 7</span> <span style="color: #000000; ">    printf(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">nData = %d\n</span><span style="color: #000000; ">"</span><span style="color: #000000; ">,nData_b);<br /></span><span style="color: #008080; "> 8</span> <span style="color: #000000; "><br /></span><span style="color: #008080; "> 9</span> <span style="color: #000000; ">    </span><span style="color: #008000; ">//</span><span style="color: #008000; "> c++宓屽叆asm鍙傝錛?/span><span style="color: #008000; text-decoration: underline; ">http://asm.sourceforge.net/articles/linasm.html</span><span style="color: #008000; "><br /></span><span style="color: #008080; ">10</span> <span style="color: #008000; "></span><span style="color: #000000; ">    asm(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">movl $2, -4(%ebp)\n\r</span><span style="color: #000000; ">"</span><span style="color: #000000; ">); </span><span style="color: #008000; ">//</span><span style="color: #008000; "> 淇敼鍙橀噺鍦板潃鍐呭</span><span style="color: #008000; "><br /></span><span style="color: #008080; ">11</span> <span style="color: #008000; "></span><span style="color: #000000; "><br /></span><span style="color: #008080; ">12</span> <span style="color: #000000; ">    </span><span style="color: #0000FF; ">int</span><span style="color: #000000; "> nData_a </span><span style="color: #000000; ">=</span><span style="color: #000000; "> nData;<br /></span><span style="color: #008080; ">13</span> <span style="color: #000000; ">    printf(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">nData = %d\n</span><span style="color: #000000; ">"</span><span style="color: #000000; ">,nData_a);<br /></span><span style="color: #008080; ">14</span> <span style="color: #000000; ">}<br /></span><span style="color: #008080; ">15</span> <span style="color: #000000; "><br /></span><span style="color: #008080; ">16</span> <span style="color: #000000; ">浣跨敤volatile杈撳嚭錛?br /></span><span style="color: #008080; ">17</span> <span style="color: #000000; ">nData </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #000000; ">1</span><span style="color: #000000; "><br /></span><span style="color: #008080; ">18</span> <span style="color: #000000; ">nData </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #000000; ">2</span><span style="color: #000000; "><br /></span><span style="color: #008080; ">19</span> <span style="color: #000000; "><br /></span><span style="color: #008080; ">20</span> <span style="color: #000000; ">涓嶄嬌鐢╲olatile杈撳嚭涓猴細<br /></span><span style="color: #008080; ">21</span> <span style="color: #000000; ">nData </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #000000; ">1</span><span style="color: #000000; "><br /></span><span style="color: #008080; ">22</span> <span style="color: #000000; ">nData </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #000000; ">1</span></div></div></div><br /></span></font> <img src ="http://m.shnenglu.com/gordon/aggbug/175763.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.shnenglu.com/gordon/" target="_blank">Gordooooon</a> 2012-05-22 15:16 <a href="http://m.shnenglu.com/gordon/archive/2012/05/22/175763.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>感谢您访问我们的网站,您可能还对以下资源感兴趣:</p> <a href="http://m.shnenglu.com/" title="精品视频久久久久">精品视频久久久久</a> <div class="friend-links"> </div> </div> </footer> <a href="http://www.lbaak.cn" target="_blank">中文字幕久久精品</a>| <a href="http://www.sztaoren.cn" target="_blank">91超碰碰碰碰久久久久久综合</a>| <a href="http://www.viparadise.com.cn" target="_blank">久久免费99精品国产自在现线 </a>| <a href="http://www.zzrich.cn" target="_blank">天天做夜夜做久久做狠狠</a>| <a href="http://www.wyhwan.cn" target="_blank">精品久久久一二三区</a>| <a href="http://www.facai365.cn" target="_blank">日产精品久久久一区二区</a>| <a href="http://www.jj123.com.cn" target="_blank">97久久精品无码一区二区</a>| <a href="http://www.11soso.cn" target="_blank">久久天天躁狠狠躁夜夜2020老熟妇 </a>| <a href="http://www.vocard.cn" target="_blank">久久精品无码专区免费 </a>| <a href="http://www.sxmkw.cn" target="_blank">久久不见久久见免费视频7</a>| <a href="http://www.xwbu.cn" target="_blank">国产精品久久久久无码av</a>| <a href="http://www.meloful.cn" target="_blank">无码任你躁久久久久久</a>| <a href="http://www.six-dream.cn" target="_blank">99精品久久精品一区二区</a>| <a href="http://www.bukrrlg.cn" target="_blank">久久这里有精品</a>| <a href="http://www.cqxy168.cn" target="_blank">久久国产免费直播</a>| <a href="http://www.lq03.cn" target="_blank">久久精品中文字幕久久</a>| <a href="http://www.znhongsheng.com.cn" target="_blank">国产亚洲美女精品久久久2020</a>| <a href="http://www.swwpb.cn" target="_blank">久久精品成人免费国产片小草 </a>| <a href="http://www.ems1.cn" target="_blank">国产午夜久久影院</a>| <a href="http://www.lidonsj.cn" target="_blank">亚洲精品乱码久久久久久按摩 </a>| <a href="http://www.ffwfwj.cn" target="_blank">久久水蜜桃亚洲av无码精品麻豆</a>| <a href="http://www.yaojiji.cn" target="_blank">精品久久久久中文字</a>| <a href="http://www.pygsbdg.cn" target="_blank">国产午夜福利精品久久2021</a>| <a href="http://www.yyyart.cn" target="_blank">久久久久亚洲av综合波多野结衣</a>| <a href="http://www.bobofans.cn" target="_blank">国产精品综合久久第一页</a>| <a href="http://www.haokan1.cn" target="_blank">99久久综合狠狠综合久久止</a>| <a href="http://www.32dd.cn" target="_blank">久久久亚洲AV波多野结衣</a>| <a href="http://www.mir716.cn" target="_blank">久久99国产精品久久99小说</a>| <a href="http://www.jisuxb.cn" target="_blank">香蕉久久影院</a>| <a href="http://www.yunshanhong.cn" target="_blank">青春久久</a>| <a href="http://www.08fq.cn" target="_blank">99精品国产免费久久久久久下载</a>| <a href="http://www.wyj325.cn" target="_blank">久久精品国产亚洲Aⅴ蜜臀色欲</a>| <a href="http://www.xnhtml.com.cn" target="_blank">好久久免费视频高清</a>| <a href="http://www.qunfaruanjian.org.cn" target="_blank">久久AV高清无码</a>| <a href="http://www.pnpxnc.cn" target="_blank">久久99久久99精品免视看动漫</a>| <a href="http://www.tianlaiedu.cn" target="_blank">日本强好片久久久久久AAA</a>| <a href="http://www.czyhfzc.cn" target="_blank">亚洲中文字幕无码久久综合网</a>| <a href="http://www.ixdsw.cn" target="_blank">97精品伊人久久久大香线蕉</a>| <a href="http://www.peizis.cn" target="_blank">亚洲AV无码久久精品成人</a>| <a href="http://www.dsifhjh1.cn" target="_blank">久久天天躁狠狠躁夜夜96流白浆</a>| <a href="http://www.vhro.cn" target="_blank">99久久精品国产高清一区二区 </a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>