﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-fengyue-随笔分类-Java</title><link>http://www.cppblog.com/fengyue/category/16229.html</link><description /><language>zh-cn</language><lastBuildDate>Sun, 30 Sep 2012 18:18:13 GMT</lastBuildDate><pubDate>Sun, 30 Sep 2012 18:18:13 GMT</pubDate><ttl>60</ttl><item><title>tomcat使用jdk1.6启动项目的报错</title><link>http://www.cppblog.com/fengyue/archive/2012/09/29/192440.html</link><dc:creator>风悦</dc:creator><author>风悦</author><pubDate>Sat, 29 Sep 2012 12:25:00 GMT</pubDate><guid>http://www.cppblog.com/fengyue/archive/2012/09/29/192440.html</guid><wfw:comment>http://www.cppblog.com/fengyue/comments/192440.html</wfw:comment><comments>http://www.cppblog.com/fengyue/archive/2012/09/29/192440.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/fengyue/comments/commentRss/192440.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/fengyue/services/trackbacks/192440.html</trackback:ping><description><![CDATA[<p>2011-07-15 12:50 java.lang.ClassFormatError: Illegal class name "[L[Ljava/lang/String;;" in class file根据网上资料看<a href="http://fm928.blog.163.com/blog/static/748135201123115355946/">http://fm928.blog.163.com/blog/static/748135201123115355946/</a></p>
<p>在java服务（tomcat）启动时 增加参数增加参数-Xverify:none</p>
<p>catalina.bat最后<br />%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS%&nbsp; -Xverify:none&nbsp;&nbsp;&nbsp; %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION%</p>
<p>就好了。应为jdk bug<br /></p><img src ="http://www.cppblog.com/fengyue/aggbug/192440.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/fengyue/" target="_blank">风悦</a> 2012-09-29 20:25 <a href="http://www.cppblog.com/fengyue/archive/2012/09/29/192440.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>memcached应用随笔</title><link>http://www.cppblog.com/fengyue/archive/2011/11/24/160897.html</link><dc:creator>风悦</dc:creator><author>风悦</author><pubDate>Thu, 24 Nov 2011 06:07:00 GMT</pubDate><guid>http://www.cppblog.com/fengyue/archive/2011/11/24/160897.html</guid><wfw:comment>http://www.cppblog.com/fengyue/comments/160897.html</wfw:comment><comments>http://www.cppblog.com/fengyue/archive/2011/11/24/160897.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/fengyue/comments/commentRss/160897.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/fengyue/services/trackbacks/160897.html</trackback:ping><description><![CDATA[<div>Memcached 是一个高性能的分布式内存对象缓存系统，用于动态Web应用以减轻数据库负载。相信大家对它并不陌生，下面把我最近开发的项目中用到的一个例子分享出来，给大家一起学习。在访问memcached时，通过synchronized实现同步。在需要操作memcached的地方可以很方便地通过类CacheFactory进行。废话少说，直接贴上代码。
<div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080">&nbsp;1</span><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top"  alt="" /><span style="color: #0000ff">import</span><span style="color: #000000">&nbsp;org.apache.log4j.BasicConfigurator;<br /></span><span style="color: #008080">&nbsp;2</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top"  alt="" /></span><span style="color: #0000ff">import</span><span style="color: #000000">&nbsp;org.apache.log4j.Logger;<br /></span><span style="color: #008080">&nbsp;3</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top"  alt="" /><br /></span><span style="color: #008080">&nbsp;4</span><span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;5</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top"  alt="" /></span><span style="color: #0000ff">import</span><span style="color: #000000">&nbsp;com.danga.MemCached.MemCachedClient;<br /></span><span style="color: #008080">&nbsp;6</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top"  alt="" /></span><span style="color: #0000ff">import</span><span style="color: #000000">&nbsp;com.danga.MemCached.SockIOPool;<br /></span><span style="color: #008080">&nbsp;7</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top"  alt="" /><br /></span><span style="color: #008080">&nbsp;8</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top"  alt="" /><br /></span><span style="color: #008080">&nbsp;9</span><span style="color: #000000"><img id="Codehighlighter1_162_228_Open_Image" onclick="this.style.display='none'; Codehighlighter1_162_228_Open_Text.style.display='none'; Codehighlighter1_162_228_Closed_Image.style.display='inline'; Codehighlighter1_162_228_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top"><img id="Codehighlighter1_162_228_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_162_228_Closed_Text.style.display='none'; Codehighlighter1_162_228_Open_Image.style.display='inline'; Codehighlighter1_162_228_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top"></span><span id="Codehighlighter1_162_228_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff">/**&nbsp;*/</span><span id="Codehighlighter1_162_228_Open_Text"><span style="color: #008000">/**</span><span style="color: #008000"><br /></span><span style="color: #008080">10</span><span style="color: #008000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />&nbsp;*&nbsp;memcache工厂类<br /></span><span style="color: #008080">11</span><span style="color: #008000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />&nbsp;*&nbsp;<br /></span><span style="color: #008080">12</span><span style="color: #008000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />&nbsp;*&nbsp;</span><span style="color: #808080">@author</span><span style="color: #008000">&nbsp;fengyue<br /></span><span style="color: #008080">13</span><span style="color: #008000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />&nbsp;*&nbsp;@date&nbsp;Feb&nbsp;16,&nbsp;2011<br /></span><span style="color: #008080">14</span><span style="color: #008000"><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top"  alt="" />&nbsp;</span><span style="color: #008000">*/</span></span><span style="color: #000000"><br /></span><span style="color: #008080">15</span><span style="color: #000000"><img id="Codehighlighter1_256_1372_Open_Image" onclick="this.style.display='none'; Codehighlighter1_256_1372_Open_Text.style.display='none'; Codehighlighter1_256_1372_Closed_Image.style.display='inline'; Codehighlighter1_256_1372_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top"><img id="Codehighlighter1_256_1372_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_256_1372_Closed_Text.style.display='none'; Codehighlighter1_256_1372_Open_Image.style.display='inline'; Codehighlighter1_256_1372_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top"></span><span style="color: #0000ff">public</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">class</span><span style="color: #000000">&nbsp;CacheFactory&nbsp;</span><span id="Codehighlighter1_256_1372_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_256_1372_Open_Text"><span style="color: #000000">{<br /></span><span style="color: #008080">16</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" /></span><span style="color: #0000ff">private</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">static</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">final</span><span style="color: #000000">&nbsp;Logger&nbsp;logger&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;Logger.getLogger(CacheFactory.</span><span style="color: #0000ff">class</span><span style="color: #000000">);<br /></span><span style="color: #008080">17</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" /></span><span style="color: #0000ff">private</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">static</span><span style="color: #000000">&nbsp;MemCachedClient&nbsp;memcache&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">null</span><span style="color: #000000">;<br /></span><span style="color: #008080">18</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" /><br /></span><span style="color: #008080">19</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" /><br /></span><span style="color: #008080">20</span><span style="color: #000000"><img id="Codehighlighter1_424_546_Open_Image" onclick="this.style.display='none'; Codehighlighter1_424_546_Open_Text.style.display='none'; Codehighlighter1_424_546_Closed_Image.style.display='inline'; Codehighlighter1_424_546_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_424_546_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_424_546_Closed_Text.style.display='none'; Codehighlighter1_424_546_Open_Image.style.display='inline'; Codehighlighter1_424_546_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top"></span><span style="color: #0000ff">public</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">static</span><span style="color: #000000">&nbsp;MemCachedClient&nbsp;getCache()&nbsp;</span><span id="Codehighlighter1_424_546_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_424_546_Open_Text"><span style="color: #000000">{<br /></span><span style="color: #008080">21</span><span style="color: #000000"><img id="Codehighlighter1_448_525_Open_Image" onclick="this.style.display='none'; Codehighlighter1_448_525_Open_Text.style.display='none'; Codehighlighter1_448_525_Closed_Image.style.display='inline'; Codehighlighter1_448_525_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_448_525_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_448_525_Closed_Text.style.display='none'; Codehighlighter1_448_525_Open_Image.style.display='inline'; Codehighlighter1_448_525_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top"></span><span style="color: #0000ff">if</span><span style="color: #000000">&nbsp;(memcache&nbsp;</span><span style="color: #000000">==</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">null</span><span style="color: #000000">)&nbsp;</span><span id="Codehighlighter1_448_525_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_448_525_Open_Text"><span style="color: #000000">{<br /></span><span style="color: #008080">22</span><span style="color: #000000"><img id="Codehighlighter1_484_523_Open_Image" onclick="this.style.display='none'; Codehighlighter1_484_523_Open_Text.style.display='none'; Codehighlighter1_484_523_Closed_Image.style.display='inline'; Codehighlighter1_484_523_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_484_523_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_484_523_Closed_Text.style.display='none'; Codehighlighter1_484_523_Open_Image.style.display='inline'; Codehighlighter1_484_523_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top"></span><span style="color: #0000ff">synchronized</span><span style="color: #000000">&nbsp;(CacheFactory.</span><span style="color: #0000ff">class</span><span style="color: #000000">)&nbsp;</span><span id="Codehighlighter1_484_523_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_484_523_Open_Text"><span style="color: #000000">{<br /></span><span style="color: #008080">23</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" /></span><span style="color: #0000ff">if</span><span style="color: #000000">&nbsp;(memcache&nbsp;</span><span style="color: #000000">==</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">null</span><span style="color: #000000">)<br /></span><span style="color: #008080">24</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />getInstance();<br /></span><span style="color: #008080">25</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"  alt="" />}</span></span><span style="color: #000000"><br /></span><span style="color: #008080">26</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"  alt="" />}</span></span><span style="color: #000000"><br /></span><span style="color: #008080">27</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" /><br /></span><span style="color: #008080">28</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" /><br /></span><span style="color: #008080">29</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" /></span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;memcache;<br /></span><span style="color: #008080">30</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"  alt="" />}</span></span><span style="color: #000000"><br /></span><span style="color: #008080">31</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" /><br /></span><span style="color: #008080">32</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" /><br /></span><span style="color: #008080">33</span><span style="color: #000000"><img id="Codehighlighter1_584_1119_Open_Image" onclick="this.style.display='none'; Codehighlighter1_584_1119_Open_Text.style.display='none'; Codehighlighter1_584_1119_Closed_Image.style.display='inline'; Codehighlighter1_584_1119_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_584_1119_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_584_1119_Closed_Text.style.display='none'; Codehighlighter1_584_1119_Open_Image.style.display='inline'; Codehighlighter1_584_1119_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top"></span><span style="color: #0000ff">private</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">static</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">void</span><span style="color: #000000">&nbsp;getInstance()&nbsp;</span><span id="Codehighlighter1_584_1119_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_584_1119_Open_Text"><span style="color: #000000">{<br /></span><span style="color: #008080">34</span><span style="color: #000000"><img id="Codehighlighter1_590_1028_Open_Image" onclick="this.style.display='none'; Codehighlighter1_590_1028_Open_Text.style.display='none'; Codehighlighter1_590_1028_Closed_Image.style.display='inline'; Codehighlighter1_590_1028_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_590_1028_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_590_1028_Closed_Text.style.display='none'; Codehighlighter1_590_1028_Open_Image.style.display='inline'; Codehighlighter1_590_1028_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top"></span><span style="color: #0000ff">try</span><span style="color: #000000">&nbsp;</span><span id="Codehighlighter1_590_1028_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_590_1028_Open_Text"><span style="color: #000000">{<br /></span><span style="color: #008080">35</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />BasicConfigurator.configure();<br /></span><span style="color: #008080">36</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />String&nbsp;serverI&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">10.185.23.17:13000</span><span style="color: #000000">"</span><span style="color: #000000">;<br /></span><span style="color: #008080">37</span><span style="color: #000000"><img id="Codehighlighter1_681_691_Open_Image" onclick="this.style.display='none'; Codehighlighter1_681_691_Open_Text.style.display='none'; Codehighlighter1_681_691_Closed_Image.style.display='inline'; Codehighlighter1_681_691_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_681_691_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_681_691_Closed_Text.style.display='none'; Codehighlighter1_681_691_Open_Image.style.display='inline'; Codehighlighter1_681_691_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top">String[]&nbsp;servers&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span id="Codehighlighter1_681_691_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_681_691_Open_Text"><span style="color: #000000">{&nbsp;serverI&nbsp;}</span></span><span style="color: #000000">;<br /></span><span style="color: #008080">38</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />SockIOPool&nbsp;pool&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;SockIOPool.getInstance();<br /></span><span style="color: #008080">39</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />pool.setServers(servers);<br /></span><span style="color: #008080">40</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />pool.setFailover(</span><span style="color: #0000ff">true</span><span style="color: #000000">);<br /></span><span style="color: #008080">41</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />pool.setInitConn(</span><span style="color: #000000">10</span><span style="color: #000000">);<br /></span><span style="color: #008080">42</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />pool.setMinConn(</span><span style="color: #000000">5</span><span style="color: #000000">);<br /></span><span style="color: #008080">43</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />pool.setMaxConn(</span><span style="color: #000000">250</span><span style="color: #000000">);<br /></span><span style="color: #008080">44</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />pool.setMaintSleep(</span><span style="color: #000000">30</span><span style="color: #000000">);<br /></span><span style="color: #008080">45</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />pool.setNagle(</span><span style="color: #0000ff">false</span><span style="color: #000000">);<br /></span><span style="color: #008080">46</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />pool.setSocketTO(</span><span style="color: #000000">3000</span><span style="color: #000000">);<br /></span><span style="color: #008080">47</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" /><br /></span><span style="color: #008080">48</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" /><br /></span><span style="color: #008080">49</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />pool.initialize();<br /></span><span style="color: #008080">50</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />memcache&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">new</span><span style="color: #000000">&nbsp;MemCachedClient();<br /></span><span style="color: #008080">51</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />memcache.add(</span><span style="color: #000000">"</span><span style="color: #000000">test</span><span style="color: #000000">"</span><span style="color: #000000">,&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">test1111111111111111111</span><span style="color: #000000">"</span><span style="color: #000000">);<br /></span><span style="color: #008080">52</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" /><br /></span><span style="color: #008080">53</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" /><br /></span><span style="color: #008080">54</span><span style="color: #000000"><img id="Codehighlighter1_1050_1117_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1050_1117_Open_Text.style.display='none'; Codehighlighter1_1050_1117_Closed_Image.style.display='inline'; Codehighlighter1_1050_1117_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_1050_1117_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_1050_1117_Closed_Text.style.display='none'; Codehighlighter1_1050_1117_Open_Image.style.display='inline'; Codehighlighter1_1050_1117_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top">}</span></span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">catch</span><span style="color: #000000">&nbsp;(Exception&nbsp;e)&nbsp;</span><span id="Codehighlighter1_1050_1117_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_1050_1117_Open_Text"><span style="color: #000000">{<br /></span><span style="color: #008080">55</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />logger.debug(</span><span style="color: #000000">"</span><span style="color: #000000">failed&nbsp;to&nbsp;init&nbsp;memcache<img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span style="color: #000000">"</span><span style="color: #000000">);<br /></span><span style="color: #008080">56</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />e.printStackTrace();<br /></span><span style="color: #008080">57</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"  alt="" />}</span></span><span style="color: #000000"><br /></span><span style="color: #008080">58</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"  alt="" />}</span></span><span style="color: #000000"><br /></span><span style="color: #008080">59</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" /><br /></span><span style="color: #008080">60</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" /><br /></span><span style="color: #008080">61</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" /><br /></span><span style="color: #008080">62</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" /><br /></span><span style="color: #008080">63</span><span style="color: #000000"><img id="Codehighlighter1_1165_1370_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1165_1370_Open_Text.style.display='none'; Codehighlighter1_1165_1370_Closed_Image.style.display='inline'; Codehighlighter1_1165_1370_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_1165_1370_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_1165_1370_Closed_Text.style.display='none'; Codehighlighter1_1165_1370_Open_Image.style.display='inline'; Codehighlighter1_1165_1370_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top"></span><span style="color: #0000ff">public</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">static</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">void</span><span style="color: #000000">&nbsp;main(String[]&nbsp;argvs)&nbsp;</span><span id="Codehighlighter1_1165_1370_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_1165_1370_Open_Text"><span style="color: #000000">{<br /></span><span style="color: #008080">64</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" /></span><span style="color: #008000">//</span><span style="color: #008000">往memcache存入缓存值</span><span style="color: #008000"><br /></span><span style="color: #008080">65</span><span style="color: #008000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" /></span><span style="color: #000000">CacheFactory.getCache().set(</span><span style="color: #000000">"</span><span style="color: #000000">myloginkey&#8220;,&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">1</span><span style="color: #000000">"</span><span style="color: #000000">,&nbsp;new&nbsp;Date(3&nbsp;*&nbsp;60&nbsp;*&nbsp;60&nbsp;*&nbsp;1000));</span><span style="color: #000000"><br /></span><span style="color: #008080">66</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" /></span><span style="color: #008000">//</span><span style="color: #008000">取出值</span><span style="color: #008000"><br /></span><span style="color: #008080">67</span><span style="color: #008000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" /></span><span style="color: #000000">CacheFactory.getCache().get(</span><span style="color: #000000">"</span><span style="color: #000000">myloginkey</span><span style="color: #000000">"</span><span style="color: #000000">);<br /></span><span style="color: #008080">68</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" /></span><span style="color: #008000">//</span><span style="color: #008000">删除</span><span style="color: #008000"><br /></span><span style="color: #008080">69</span><span style="color: #008000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" /></span><span style="color: #000000">CacheFactory.getCache().delete(</span><span style="color: #000000">"</span><span style="color: #000000">myloginkey</span><span style="color: #000000">"</span><span style="color: #000000">);<br /></span><span style="color: #008080">70</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" /></span><span style="color: #0000ff">return</span><span style="color: #000000">;<br /></span><span style="color: #008080">71</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"  alt="" />}</span></span><span style="color: #000000"><br /></span><span style="color: #008080">72</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top"  alt="" />}</span></span></div><br /></div><img src ="http://www.cppblog.com/fengyue/aggbug/160897.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/fengyue/" target="_blank">风悦</a> 2011-11-24 14:07 <a href="http://www.cppblog.com/fengyue/archive/2011/11/24/160897.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>