<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule">
<channel>
    <title>大罗-PHP/Python博客 - 技术</title>
    <link>http://www.luochunhui.com/</link>
    <description>标准的八零年代青年，充分的自信，追求自由。在真实的上海，虚拟的网络中拼搏，为了自己人生的目标，追求着，永不松懈 </description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.5.1 - http://www.s9y.org/</generator>
    
    

<item>
    <title>Django 1.2 alpha1 发布</title>
    <link>http://www.luochunhui.com/index.php?/id/533</link>
            <category>技术</category>
    
    <comments>http://www.luochunhui.com/index.php?/id/533#comments</comments>
    <wfw:comment>http://www.luochunhui.com/wfwcomment.php?cid=533</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.luochunhui.com/rss.php?version=2.0&amp;type=comments&amp;cid=533</wfw:commentRss>
    

    <author>nospam@example.com (rollenc)</author>
    <content:encoded>
    不兼容的改动：&lt;br /&gt;
&lt;br /&gt;
1. 增加CSRF（防跨域提交表单） 这个改动比较大。相对1.1来说，所有的表单中都需要加上CSRF的HTML标签，不然表单数据将无法通过验证。&lt;br /&gt;
2. IF标签将更加强大。 现在可以使用 {%if a==b and b&lt;c%}等基本比较操作符了。and，or等，将不能作为变量名放在{%if%}中了&lt;br /&gt;
3. 惰性对象。 提供一个惰性封装，只有在需要获得该对象的值时，才加载数据&lt;br /&gt;
4. 在Model对象中__dict__改变，增加了_state属性&lt;br /&gt;
5. 在字段类中，get_db_prep_*() 方法改变了，增加了几个参数&lt;br /&gt;
6. 模板tags的状态BUG修正。在之前版本中，在使用了模板缓存的情况下，带有状态属性的tags可能导致异常，这一个bug已经修正&lt;br /&gt;
7. 测试运行后，将返回状态码0表示正常，或1等其他错误码&lt;br /&gt;
&lt;br /&gt;
新功能：&lt;br /&gt;
1. CSRF支持&lt;br /&gt;
2. EMAIL后端支持。 现在可以将错误报告的EMAIL发送到文件，console甚至内存中。&lt;br /&gt;
3. 消息框架 django增加了一个message框架，可以基于session或者cookie进行记录。以前只能给已登录用户存储message。（这里的message指的是flash message）&lt;br /&gt;
4. 多数据库支持&lt;br /&gt;
5. 智能的if标签&lt;br /&gt;
6. 模板缓存&lt;br /&gt;
7. 原生的key搜索。可使用 self.get(first_name=first_name, last_name=last_name) ，以前只能使用主键ID&lt;br /&gt;
8. 更快的测试错误处理&lt;br /&gt;
9. 本地化支持改进&lt;br /&gt;
10. ModelAdmin中增加readonly_fields&lt;br /&gt;
11. 可定制的语法高亮&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
接下来，django团队将在3月2号发布rc版本，3月9号发布1.2的正式版本&lt;br /&gt;
&lt;br /&gt;
更多信息，请查阅：&lt;a href=&quot;http://docs.djangoproject.com/en/dev/releases/1.2-alpha-1/&quot;&gt;官方声明&lt;/a&gt; 
    </content:encoded>

    <pubDate>Thu, 07 Jan 2010 10:39:09 +0800</pubDate>
    <guid isPermaLink="false">http://www.luochunhui.com/index.php?/id/533</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license><category>django</category>
<category>python</category>

</item>
<item>
    <title>修复mako html编辑器语法的高亮问题</title>
    <link>http://www.luochunhui.com/index.php?/id/532</link>
            <category>技术</category>
    
    <comments>http://www.luochunhui.com/index.php?/id/532#comments</comments>
    <wfw:comment>http://www.luochunhui.com/wfwcomment.php?cid=532</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.luochunhui.com/rss.php?version=2.0&amp;type=comments&amp;cid=532</wfw:commentRss>
    

    <author>nospam@example.com (rollenc)</author>
    <content:encoded>
    mako中的%标记方式让不少编辑器抓狂，包括aptana,eclipse,textmate等。受asp的影响，&amp;lt;%是作为服务器脚本语言的开始标记，相应的，%&amp;gt;为结束标记。&lt;br /&gt;

在mako中，示例代码如下：&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;html&quot;&gt;
&lt; %inherit file=&quot;/base.mako&quot; /&gt;
&lt; %def name=&quot;head_title()&quot;&gt;
    rollenc拼博-PHP博客
&lt;/ %def&gt;
&lt;p&gt;Here is a p&lt;/p&gt;
&lt;/pre&gt;
在这段代码中，由于没有 %&amp;gt; 结束标记，编辑器将认为从一行后所有的代码均为服务器脚本，而非html代码，导致html高亮，格式等功能全部失效。&lt;br /&gt;

解决办法：替换&amp;lt;%脚本&lt;br /&gt;
mako支持预处理。即在mako模板引擎处理之前，自己写一个脚本来预先替换或作其他操作。将&amp;lt;%inherit file=&quot;/base.mako&quot; /&amp;gt; 修改为 &amp;lt;makoinherit file=&quot;/base.mako&quot; /&amp;gt; 是个不错的注意。既不违反XHTML的规定，又避免了抓狂的 &amp;lt;%&lt;br /&gt;

1. 在建立TemplateLookup对象时，增加preprocessor参数，在交给mako处理之前，还原&amp;lt;mako:为&amp;lt;%&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;py&quot;&gt;
def my_preprocessor(text): 
        text = re.sub(r&#039;&lt;(/?)mako:&#039;, r&quot;&lt;\1%&quot;, text)
        return text

lookup = TemplateLookup(
        #....
        preprocessor = my_preprocessor,
        )
&lt;/pre&gt;
若在pylons中，则修改文件：config/environment.py&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;py&quot;&gt;
# Create the Mako TemplateLookup, with the default auto-escaping
    def my_preprocessor(text): 
        text = re.sub(r&#039;&lt;(/?)mako:&#039;, r&quot;&lt;\1%&quot;, text)
        return text
    config[&#039;pylons.app_globals&#039;].mako_lookup = TemplateLookup(
        directories=paths[&#039;templates&#039;],
        error_handler=handle_mako_error,
        module_directory=os.path.join(app_conf[&#039;cache_dir&#039;], &#039;templates&#039;),
        input_encoding=&#039;utf-8&#039;, default_filters=[&#039;escape&#039;],
        imports=[&#039;from webhelpers.html import escape&#039;],
        preprocessor = my_preprocessor,
        )
&lt;/pre&gt;
增加了2，3，4，11行。

2. 替换.mako模板代码中的&amp;lt;% , &amp;lt;/%。替换后，上面示例代码如下：&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;html&quot;&gt;
&lt;mako:inherit file=&quot;/base.mako&quot; /&gt;
&lt;mako:def name=&quot;head_title()&quot;&gt;
    rollenc拼博-PHP博客
&lt;/mako:def&gt;
&lt;p&gt;Here is a p&lt;/p&gt;
&lt;/pre&gt;

 
    </content:encoded>

    <pubDate>Sun, 03 Jan 2010 05:06:50 +0800</pubDate>
    <guid isPermaLink="false">http://www.luochunhui.com/index.php?/id/532</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license><category>mako</category>
<category>pylons</category>
<category>python</category>

</item>
<item>
    <title>How to install Pylons in Ubuntu</title>
    <link>http://www.luochunhui.com/index.php?/id/530</link>
            <category>技术</category>
    
    <comments>http://www.luochunhui.com/index.php?/id/530#comments</comments>
    <wfw:comment>http://www.luochunhui.com/wfwcomment.php?cid=530</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.luochunhui.com/rss.php?version=2.0&amp;type=comments&amp;cid=530</wfw:commentRss>
    

    <author>nospam@example.com (rollenc)</author>
    <content:encoded>
    Env:&lt;br /&gt;
  Python 2.5&lt;br /&gt;
  Ubuntu&lt;br /&gt;
&lt;br /&gt;
1. Install paste&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;bash&quot;&gt;&lt;br /&gt;
sudo easy_install-2.5 paste&lt;br /&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
2. Install pylons&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;bash&quot;&gt;&lt;br /&gt;
sudo easy_install-2.5 Pylons&lt;br /&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
3. install SQLAlchemy if you&#039;d like to use&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;bash&quot;&gt;&lt;br /&gt;
sudo easy_install-2.5 SQLAlchemy&lt;br /&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
4. create a pylons project:&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;bash&quot;&gt;&lt;br /&gt;
paster create --template=pylons test&lt;br /&gt;
&lt;/pre&gt;&lt;br /&gt;
That will ask you two questions:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;Enter template_engine (mako/genshi/jinja2/etc: Template language) [&#039;mako&#039;]: mako&lt;br /&gt;
Enter sqlalchemy (True/False: Include SQLAlchemy 0.5 configuration) [False]: True&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
5. create a deployment.ini&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;bash&quot;&gt;&lt;br /&gt;
cd test&lt;br /&gt;
cp test/config/deployment.ini_tmpl test/config/deployment.ini&lt;br /&gt;
vi deployment.ini&lt;br /&gt;
&lt;/pre&gt;&lt;br /&gt;
modify the email_to, db setting or others to fit in with you&lt;br /&gt;
&lt;br /&gt;
6. start the test server&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;bash&quot;&gt;&lt;br /&gt;
$paster serve --reload development.ini&lt;br /&gt;
Starting subprocess with file monitor&lt;br /&gt;
Starting server in PID 12212.&lt;br /&gt;
serving on http://127.0.0.1:5000&lt;br /&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
You will see a pylons welcome page when you open http://127.0.0.1:5000 in your favorite browser. &lt;br /&gt;
&lt;br /&gt;
7. create a new controller&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;bash&quot;&gt;&lt;br /&gt;
paster controller hello&lt;br /&gt;
&lt;/pre&gt;&lt;br /&gt;
Visit http://127.0.0.1:5000/hello/index and you will see a text page: &quot;Hello World&quot;&lt;br /&gt;
&lt;br /&gt;
All job done. Have your fan.&lt;br /&gt;
&lt;br /&gt;
Notice: make sure you&#039;ve added the version 2.5 into &lt;strong&gt;easy_install&lt;/strong&gt; command when you have multiply python version in your system.&lt;br /&gt;
 
    </content:encoded>

    <pubDate>Fri, 01 Jan 2010 13:28:40 +0800</pubDate>
    <guid isPermaLink="false">http://www.luochunhui.com/index.php?/id/530</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license><category>framework</category>
<category>python</category>

</item>
<item>
    <title>豆瓣DB开源：beansdb</title>
    <link>http://www.luochunhui.com/index.php?/id/528</link>
            <category>技术</category>
    
    <comments>http://www.luochunhui.com/index.php?/id/528#comments</comments>
    <wfw:comment>http://www.luochunhui.com/wfwcomment.php?cid=528</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.luochunhui.com/rss.php?version=2.0&amp;type=comments&amp;cid=528</wfw:commentRss>
    

    <author>nospam@example.com (rollenc)</author>
    <content:encoded>
    &lt;strong&gt;介绍&lt;/strong&gt;&lt;br /&gt;
BeansDB 是一个主要针对大数据量、高可用性的分布式KeyValue存储系统，采用HashTree和简化的版本号来快速同步保证最终一致性（弱），一个简化版的Dynamo。&lt;br /&gt;
&lt;br /&gt;
它采用类似memcached的去中心化结构，在客户端实现数据路由。目前只提供了Python版本的客户端，其它语言的客户端可以由memcached的客户端稍加改造得到。&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;特性&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
高可用：通过多个可读写的用于备份实现高可用&lt;br /&gt;
最终一致性：通过哈希树实现快速完整数据同步（短时间内数据可能不一致）&lt;br /&gt;
容易扩展：可以在不中断服务的情况下进行容量扩展。&lt;br /&gt;
高性能：异步IO和高性能的KeyValue数据TokyoCabinet&lt;br /&gt;
可配置的可用性和一致性：通过N,W,R进行配置&lt;br /&gt;
简单协议：Memcache兼容协议，大量可用客户端&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;性能&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
在小数据集上，它跟memcached一样快：&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;网址&lt;/strong&gt;&lt;br /&gt;
主页：&lt;a href=&quot;http://code.google.com/p/beansdb/&quot;&gt;http://code.google.com/p/beansdb/&lt;/a&gt;&lt;br /&gt;
SVN源码: &lt;a href=&quot;http://beansdb.googlecode.com/svn/trunk/&quot;&gt;http://beansdb.googlecode.com/svn/trunk/&lt;/a&gt; 
    </content:encoded>

    <pubDate>Thu, 31 Dec 2009 02:01:06 +0800</pubDate>
    <guid isPermaLink="false">http://www.luochunhui.com/index.php?/id/528</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license><category>Database opensource</category>

</item>
<item>
    <title>bpython, A fancy interface to the Python interpreter</title>
    <link>http://www.luochunhui.com/index.php?/id/527</link>
            <category>技术</category>
    
    <comments>http://www.luochunhui.com/index.php?/id/527#comments</comments>
    <wfw:comment>http://www.luochunhui.com/wfwcomment.php?cid=527</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.luochunhui.com/rss.php?version=2.0&amp;type=comments&amp;cid=527</wfw:commentRss>
    

    <author>nospam@example.com (rollenc)</author>
    <content:encoded>
    bpython is a fancy interface to the Python interpreter for Unix-like operating systems (I hear it works fine on OS X). It is released under the MIT License. It has the following features:&lt;br /&gt;
&lt;br /&gt;
In-line syntax highlighting.&lt;br /&gt;
Readline-like autocomplete with suggestions displayed as you type.&lt;br /&gt;
Expected parameter list for any Python function.&lt;br /&gt;
&quot;Rewind&quot; function to pop the last line of code from memory and re-evaluate.&lt;br /&gt;
Send the code you&#039;ve entered off to a pastebin.&lt;br /&gt;
Save the code you&#039;ve entered to a file.&lt;br /&gt;
Auto-indentation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install: &lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
$ sudo apt-get install python-pygments&lt;br /&gt;
$ curl http://bpython-interpreter.org/releases/bpython-0.9.5.2.tar.gz&lt;br /&gt;
$ tar zxvf bpython-0.9.5.2.tar.gz&lt;br /&gt;
$ cd bpy*&lt;br /&gt;
$ sudo python setup.py install&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Or use easy_install simplely,&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
$ sudo easy_install bpython&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&lt;code lang=&quot;bash&quot;&gt;&lt;br /&gt;
$ bpython&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Sceenshot:&lt;br /&gt;
&lt;br /&gt;
&lt;img src=&quot;http://bpython-interpreter.org/static/screenshots/6.png&quot; alt=&quot;&quot;  /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For more, see &lt;a href=&quot;http://bpython-interpreter.org/home/&quot;&gt;the bpython home&lt;/a&gt; or just &lt;a href=&quot;http://bpython-interpreter.org/screenshots/&quot;&gt;skip right to the screenshots.&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 
    </content:encoded>

    <pubDate>Tue, 29 Dec 2009 14:38:29 +0800</pubDate>
    <guid isPermaLink="false">http://www.luochunhui.com/index.php?/id/527</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license><category>python</category>

</item>
<item>
    <title>Serendipity 1.5 发布</title>
    <link>http://www.luochunhui.com/index.php?/id/526</link>
            <category>技术</category>
    
    <comments>http://www.luochunhui.com/index.php?/id/526#comments</comments>
    <wfw:comment>http://www.luochunhui.com/wfwcomment.php?cid=526</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.luochunhui.com/rss.php?version=2.0&amp;type=comments&amp;cid=526</wfw:commentRss>
    

    <author>nospam@example.com (rollenc)</author>
    <content:encoded>
    原文： &lt;a href=&quot;http://blog.s9y.org/archives/211-Serendipity-1.5-released.html&quot;&gt;http://blog.s9y.org/archives/211-Serendipity-1.5-released.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Serendipity团队很自豪的发布了Serendipity 1.5版本。 之前的beta版本在多数情况下都能正常工作，现在是最终发布的时候了：）&lt;br /&gt;
The Serendipity Team is proud to present the final release of Serendipity 1.5. While the earlier beta versions are proven to work fine for many people, it was finally time to package up a real release. ;)&lt;br /&gt;
&lt;br /&gt;
本版本改变了密码存储机制，使用salted后的SHA1代替了原来简单的MD5编码。这一改变后，黑客将无法通过数据库破解原密码。另一个改变是增加了PHP5.3的兼容性。&lt;br /&gt;
This version mainly addresses login security by changing our method how passwords are stored to use salted SHA1 checksums instead of plain MD5 checksums. This makes password retrieval (rainbow attacks, see special blog posting) through the database virtually impossible. Another thing is improved PHP 5.3 compatibility.&lt;br /&gt;
&lt;br /&gt;
对于使用Xinha 所见即所得编辑器的用户来讲，现在可以通过自定义&quot;my_custom.js&quot;来修改编辑器面板的样式了。该文件在template目录下（在htmlarea/子目录下我们已经准备了一个默认的草稿文件供你参考或还原）。&lt;br /&gt;
For users of our Bundled WYSIWYG-Editor Xinha users now have the ability to easily customize the appearance of this panel through a &quot;my_custom.js&quot; file inside the template directory (a draft of such a file can be found as fallback default in the htmlarea/ subdirectory).&lt;br /&gt;
&lt;br /&gt;
我们给开发者提供了一个很酷的新功能，在模板中可以注册插件API，来执行一些特殊的需求。本功能不需要安装任何事件组件。&lt;br /&gt;
One cool new feature for developers is that now also templates can register themselves inside the plugin API hooks to execute specific things, that don&#039;t require installation of an event plugin.&lt;br /&gt;
&lt;br /&gt;
其他新的内容：&lt;br /&gt;
新的事件API钩子&lt;br /&gt;
修正了PDF缩略图&lt;br /&gt;
拖拽组件时，边框将可以自动滚动调整&lt;br /&gt;
支持UTC时区&lt;br /&gt;
增强了Smarty函数，将S9Y打造成CMS江更为简单&lt;br /&gt;
快速搜索中，如果返回结果过少，将启用通配符搜索 (译者注：这个功能使得S9Y支持中文搜索了)&lt;br /&gt;
在Akismet新支持Typepad 反垃圾邮件验证&lt;br /&gt;
Other news include:&lt;br /&gt;
new event API hooks&lt;br /&gt;
fixed PDF thumbnail generation&lt;br /&gt;
ability to auto-scroll on borders when Drag/Dropping plugins&lt;br /&gt;
UTC server time zone support&lt;br /&gt;
improvements in the Smarty functions to easier use Serendipity as a CMS for individual entry output.&lt;br /&gt;
quicksearch improvements for doing a wildcard-search when too few searchresults were found on a fixed searchterm&lt;br /&gt;
support for Typepad anti-spam server-checks, additionally to Akismet&lt;br /&gt;
&lt;br /&gt;
在1.5beta-1之后的主要更新包括：&lt;br /&gt;
兼容PHP5.3.0&lt;br /&gt;
禁止上传含有.PHP.的文件，避免apache启用 MimeMagic-Modules产生的安全漏洞&lt;br /&gt;
实验PDO,支持SQLite&lt;br /&gt;
改进了评论管理，增加了一些有用的工具&lt;br /&gt;
&lt;br /&gt;
Minor improvements since the 1.5-beta1 release:&lt;br /&gt;
more PHP 5.3.0 compatibility improvements&lt;br /&gt;
Disallow uploading any files that contain &quot;.php.&quot; in the filename for extra security with Apache MimeMagic-Modules&lt;br /&gt;
expermiental PDO:SQlite support&lt;br /&gt;
usability improvements for the comment moderation panel (bottom-navigation, removed border increase)&lt;br /&gt;
&lt;br /&gt;
之前的各个版本可以很容易的升级到最新的版本。解压，上传，然后访问你的管理面板进行数据库升级就可以了。在使用旧密码进行第一次登录后，S9Y将使用新的格式存储你的密码。在更新之前，请先做好备份，并认真阅读升级文档。&lt;br /&gt;
The current release can be easily installed on any previous Serendipity installation. Just unpack, upload and visit your admin panel to perform possible database upgrades. Upon first login with an old password, Serendipity will store your old password in the new format - please be sure to make a backup of your Database prior to upgrading, and read the upgrade pointers on Upgrading Serendipity.&lt;br /&gt;
&lt;br /&gt;
祝你使用S9Y愉快。有任何问题，请将它发布到我们的论坛上。&lt;br /&gt;
Have fun using Serendipity, and let us know on the Forums if you have any issues!&lt;br /&gt;
&lt;br /&gt;
 
    </content:encoded>

    <pubDate>Tue, 22 Dec 2009 13:26:54 +0800</pubDate>
    <guid isPermaLink="false">http://www.luochunhui.com/index.php?/id/526</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>How to Install Trac &amp; MySQL &amp; Subversion &amp; Nginx</title>
    <link>http://www.luochunhui.com/index.php?/id/525</link>
            <category>技术</category>
    
    <comments>http://www.luochunhui.com/index.php?/id/525#comments</comments>
    <wfw:comment>http://www.luochunhui.com/wfwcomment.php?cid=525</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.luochunhui.com/rss.php?version=2.0&amp;type=comments&amp;cid=525</wfw:commentRss>
    

    <author>nospam@example.com (rollenc)</author>
    <content:encoded>
    My Env: &lt;br /&gt;
  Ubuntu 8.04&lt;br /&gt;
  python 2.5&lt;br /&gt;
&lt;br /&gt;
Step:&lt;br /&gt;
1. sudo apt-get install python-subversion python-mysqldb&lt;br /&gt;
2. sudo easy_install Trac&lt;br /&gt;
3. sudo useradd trac&lt;br /&gt;
4. sudo su trac&lt;br /&gt;
5. trac-admin /home/trac/luochunhui.com initenv&lt;br /&gt;
&lt;blockquote&gt;Project Name [My Project]&gt; Blog&lt;br /&gt;
Database connection string [sqlite:db/trac.db]&gt; mysql://username:password@localhost/trac&lt;br /&gt;
Repository type [svn]&gt; svn&lt;br /&gt;
Path to repository [/path/to/repos]&gt; /home/svn/blog &lt;/blockquote&gt;&lt;br /&gt;
6. nohup tracd --port 8290 -b trac.luochunhui.com /home/trac/luochunhui.com/ &amp;amp;&lt;br /&gt;
7. exit &lt;br /&gt;
visit trac.luochunhui.com:8290 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Next: auth &amp;amp; use nginx&lt;br /&gt;
&lt;br /&gt;
8. sudo su tracd&lt;br /&gt;
9. cd /home/trac&lt;br /&gt;
10. trac-admin luochunhui.com/ permission remove anonymous BROWSER_VIEW CHANGESET_VIEW FILE_VIEW LOG_VIEW MILESTONE_VIEW REPORT_SQL_VIEW REPORT_VIEW ROADMAP_VIEW SEARCH_VIEW TICKET_VIEW  WIKI_VIEW TIMELINE_VIEW &lt;br /&gt;
11.  trac-admin luochunhui.com/ permission add authenticated BROWSER_VIEW CHANGESET_VIEW FILE_VIEW LOG_VIEW MILESTONE_VIEW REPORT_SQL_VIEW REPORT_VIEW ROADMAP_VIEW SEARCH_VIEW TICKET_VIEW  WIKI_VIEW TIMELINE_VIEW&lt;br /&gt;
12. htpasswd  -c  conf/trac.htpasswd username&lt;br /&gt;
13. killall tracd&lt;br /&gt;
14. nohup tracd --port 8290 -b trac.luochunhui.com /home/trac/luochunhui.com --basic-auth=&quot;*&quot;,/home/trac/luochunhui.com/conf/trac.htpasswd,trac.luochunhui.com &amp;amp;&lt;br /&gt;
15. exit //exit trac user&lt;br /&gt;
14. sudo vi /etc/nginx/sites-available/trac.luochunhui.com&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
upstream trac_rollenc {&lt;br /&gt;
	server trac.luochunhui.com:8290;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
	listen 80;&lt;br /&gt;
	server_name trac.luochunhui.com;&lt;br /&gt;
	access_log /var/log/nginx/trac.access.log main;&lt;br /&gt;
	error_log /var/log/nginx/trac.error.log info;&lt;br /&gt;
	location / {&lt;br /&gt;
		proxy_pass http://trac_rollenc;&lt;br /&gt;
	#	include         /etc/nginx/proxy.conf;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
15. sudo ln -sf /etc/nginx/sites-available/trac.luochunhui.com /etc/nginx/sites-enable/trac.luochunhui.com&lt;br /&gt;
16. sudo nginx -t&lt;br /&gt;
17. sudo /etc/init.d/nginx restart&lt;br /&gt;
&lt;br /&gt;
visit trac.luochunhui.com&lt;br /&gt;
and you will see some error message because the anonymous is deny. &lt;br /&gt;
click &quot;login&quot; and input your username and password.&lt;br /&gt;
Enjoy it.&lt;br /&gt;
&lt;br /&gt;
ALL DONE.&lt;br /&gt;
 
    </content:encoded>

    <pubDate>Fri, 18 Dec 2009 03:25:39 +0800</pubDate>
    <guid isPermaLink="false">http://www.luochunhui.com/index.php?/id/525</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>MySQL prepared statements VS Direct execution</title>
    <link>http://www.luochunhui.com/index.php?/id/523</link>
            <category>技术</category>
    
    <comments>http://www.luochunhui.com/index.php?/id/523#comments</comments>
    <wfw:comment>http://www.luochunhui.com/wfwcomment.php?cid=523</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.luochunhui.com/rss.php?version=2.0&amp;type=comments&amp;cid=523</wfw:commentRss>
    

    <author>nospam@example.com (rollenc)</author>
    <content:encoded>
    1. Cache&lt;br /&gt;
  Direct execution can use MySQL cache when two sqls are the absolutely same .&lt;br /&gt;
  Prepared execution can&#039;t use MySQL cache, even if no placeholders were employed.  &lt;br /&gt;
&lt;br /&gt;
2. Speed&lt;br /&gt;
  Direct execution query need to be parsed every time. &lt;br /&gt;
  Prepared execution query is parsed only once.&lt;br /&gt;
  &lt;blockquote&gt;Prepared statements might not provide a performance increase in some situations. For best results, test your application both with prepared and nonprepared statements and choose whichever yields best performance.&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
3. Network&lt;br /&gt;
  Direct execution sends all the query to MySQL services.&lt;br /&gt;
  Prepared execution sends twice, The first is for prepared query, then the arguments. &lt;br /&gt;
  If you call a prepared more than once, prepared execution can reduce the network traffic.&lt;br /&gt;
&lt;br /&gt;
4. Safe&lt;br /&gt;
  Direct execution might cause a sql inject if the programmer doesn&#039;t handle the unsafe input rightly and carefully.&lt;br /&gt;
  Prepared execution is safe because the query and the arguments are split.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ref:&lt;br /&gt;
1. http://dev.mysql.com/doc/refman/5.0/en/c-api-prepared-statements.html&lt;br /&gt;
2. http://dev.mysql.com/doc/refman/5.0/en/query-cache-operation.html&lt;br /&gt;
&lt;br /&gt;
   
    </content:encoded>

    <pubDate>Wed, 02 Dec 2009 05:29:35 +0800</pubDate>
    <guid isPermaLink="false">http://www.luochunhui.com/index.php?/id/523</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license><category>mysql stmt</category>

</item>
<item>
    <title>popen实现PHP并发方法</title>
    <link>http://www.luochunhui.com/index.php?/id/516</link>
            <category>技术</category>
    
    <comments>http://www.luochunhui.com/index.php?/id/516#comments</comments>
    <wfw:comment>http://www.luochunhui.com/wfwcomment.php?cid=516</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.luochunhui.com/rss.php?version=2.0&amp;type=comments&amp;cid=516</wfw:commentRss>
    

    <author>nospam@example.com (rollenc)</author>
    <content:encoded>
    用途: 当业务需要调用一个比较耗时外部资源时使用， 最常见的是从外部API获取相关内容&lt;br /&gt;
&lt;br /&gt;
使用方法： &lt;br /&gt;
1. 建立外部资源脚本。 如示例中使用t.sh。 当然， 也可以直接使用curl等命令行&lt;br /&gt;
2. 准备好参数， 提供给pipe脚本&lt;br /&gt;
2. 使用ｐｏｐｅｎ调用脚本。 调用之后，就不用关心了。&lt;br /&gt;
3. 开始其他的和pipe不相关的逻辑处理&lt;br /&gt;
4. 其他处理完成之后， 使用fgets等方式，获取ｐｏｐｅｎ的数据&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
示例代码：&lt;br /&gt;
&lt;br /&gt;
php程序：&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;php&quot;&gt;&lt;br /&gt;
# get argument for pipe here if it has.&lt;br /&gt;
&lt;br /&gt;
#start pipe&lt;br /&gt;
echo &#039;call ｐｏｐｅｎ start: &#039;. date(&quot;H:i:s&quot;), &quot;\n&quot;;&lt;br /&gt;
$pipe = ｐｏｐｅｎ(dirname(__FILE__) . &#039;/t.sh&#039;, &#039;r&#039;);&lt;br /&gt;
echo &#039;call ｐｏｐｅｎ end: &#039;. date(&quot;H:i:s&quot;), &quot;\n&quot;;&lt;br /&gt;
&lt;br /&gt;
#Other code here&lt;br /&gt;
sleep(5);&lt;br /&gt;
echo &quot;Here is my code. time: &quot; . date(&quot;H:i:s&quot;), &quot;\n&quot;;&lt;br /&gt;
&lt;br /&gt;
#read pipe result&lt;br /&gt;
while ($s = fgets($pipe,1024)) {&lt;br /&gt;
    echo $s;&lt;br /&gt;
}&lt;br /&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
pipe脚本：&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;bash&quot;&gt;&lt;br /&gt;
echo 1, `date +%T`;&lt;br /&gt;
sleep 1;&lt;br /&gt;
echo 2, `date +%T`;&lt;br /&gt;
sleep 10;&lt;br /&gt;
echo 3, `date +%T`;&lt;br /&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
输出如下：&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;undefined&quot;&gt;&lt;br /&gt;
call ｐｏｐｅｎ start: 10:16:40&lt;br /&gt;
call ｐｏｐｅｎ end: 10:16:40&lt;br /&gt;
Here is my code. time: 10:16:45&lt;br /&gt;
1, 10:16:40&lt;br /&gt;
2, 10:16:41&lt;br /&gt;
3, 10:16:51&lt;br /&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
代码方面， 我们有三个sleep。&lt;br /&gt;
php中一个 sleep 5,&lt;br /&gt;
sh中两个sleep， 10＋1&lt;br /&gt;
如果使用串行的方式， 那么用时应该是10＋1＋5 ＝ 16秒。&lt;br /&gt;
而使用pipe方式， 用时仅为：max(php, pipe) = max(5,11) = 11秒。&lt;br /&gt;
&lt;br /&gt;
PS:很抱歉，空间服务商看起来不喜欢ｐｏｐｅｎ这个字眼，　所以只能将起替换成全角的了。请在使用时，替换一下吧：）&lt;br /&gt;
 
    </content:encoded>

    <pubDate>Sat, 25 Apr 2009 01:20:49 +0800</pubDate>
    <guid isPermaLink="false">http://www.luochunhui.com/index.php?/id/516</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license><category>php</category>

</item>
<item>
    <title>Subversion迁移方法</title>
    <link>http://www.luochunhui.com/index.php?/id/510</link>
            <category>技术</category>
    
    <comments>http://www.luochunhui.com/index.php?/id/510#comments</comments>
    <wfw:comment>http://www.luochunhui.com/wfwcomment.php?cid=510</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.luochunhui.com/rss.php?version=2.0&amp;type=comments&amp;cid=510</wfw:commentRss>
    

    <author>nospam@example.com (rollenc)</author>
    <content:encoded>
    由于服务器修改，或者备份的原因，你可能需要对Subversio的源进行迁移。&lt;br /&gt;
迁移方法有几中。 最直接的是将库文件直接copy到新的位置就好。&lt;br /&gt;
如果原来的svn版本和新的svn版本不一样的话， 这样迁移并不是很安全。&lt;br /&gt;
&lt;br /&gt;
更安全的方式也很简单，如下：&lt;br /&gt;
&lt;br /&gt;
1. 导出：  &lt;br /&gt;
svnadmin dump ~/svn/dede &gt; svndump &lt;br /&gt;
&lt;br /&gt;
2. 将svndump文件copy到新的位置&lt;br /&gt;
&lt;br /&gt;
3. 导入dump文件：&lt;br /&gt;
svnadmin load /home/svn/dede &lt; svndump&lt;br /&gt;
&lt;br /&gt;
完成 
    </content:encoded>

    <pubDate>Sun, 19 Apr 2009 11:26:33 +0800</pubDate>
    <guid isPermaLink="false">http://www.luochunhui.com/index.php?/id/510</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license><category>subversion</category>

</item>
<item>
    <title>Thrift安装</title>
    <link>http://www.luochunhui.com/index.php?/id/504</link>
            <category>技术</category>
    
    <comments>http://www.luochunhui.com/index.php?/id/504#comments</comments>
    <wfw:comment>http://www.luochunhui.com/wfwcomment.php?cid=504</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.luochunhui.com/rss.php?version=2.0&amp;type=comments&amp;cid=504</wfw:commentRss>
    

    <author>nospam@example.com (rollenc)</author>
    <content:encoded>
    1. 安装依赖的包&lt;br /&gt;
sudo apt-get install libboost-dev automake libtool flex bison&lt;br /&gt;
&lt;br /&gt;
2. 安装ruby， gem&lt;br /&gt;
sudo apt-get install ruby rubygem ruby1.8-dev&lt;br /&gt;
&lt;br /&gt;
3.下面make时需要require mkmf,需要sys-proctable&lt;br /&gt;
sudo gem install sys-proctable&lt;br /&gt;
&lt;br /&gt;
4. 下载thrift，解压&lt;br /&gt;
wget -O thrift.tgz &quot;http://gitweb.thrift-rpc.org/?p=thrift.git;a=snapshot;h=HEAD;sf=tgz&quot;&lt;br /&gt;
tar -xzf thrift.tgz&lt;br /&gt;
cd thrift&lt;br /&gt;
&lt;br /&gt;
4. 安装&lt;br /&gt;
./bootstrap.sh&lt;br /&gt;
CONFIG_SHELL=/bin/bash ./configure --pref-x=/opt&lt;br /&gt;
make &amp;&amp;amp; sudo make install&lt;br /&gt;
&lt;br /&gt;
 
    </content:encoded>

    <pubDate>Fri, 20 Mar 2009 11:28:00 +0800</pubDate>
    <guid isPermaLink="false">http://www.luochunhui.com/index.php?/id/504</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>VIM for php</title>
    <link>http://www.luochunhui.com/index.php?/id/503</link>
            <category>技术</category>
    
    <comments>http://www.luochunhui.com/index.php?/id/503#comments</comments>
    <wfw:comment>http://www.luochunhui.com/wfwcomment.php?cid=503</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.luochunhui.com/rss.php?version=2.0&amp;type=comments&amp;cid=503</wfw:commentRss>
    

    <author>nospam@example.com (rollenc)</author>
    <content:encoded>
    vim的确是个好东西。 简单又快捷。针对在Vim编辑PHP文件，以下是在Ubuntu中的Vim安装及配置：&lt;br /&gt;
&lt;br /&gt;
1. sudo apt-get install vim&lt;br /&gt;
2. sudo vi /etc/vim/vimrc&lt;br /&gt;
  根据vimrc中的提示，Uncommenting一些需要的配置。 支持PHP主要需要解除注释的有以下几处： &lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&#039;打开语法高亮&lt;br /&gt;
  syntax on  &lt;br /&gt;
&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&#039;记录上次文件的编辑位置&lt;br /&gt;
if has(&quot;autocmd&quot;)&lt;br /&gt;
  au BufReadPost * if line(&quot;&#039;\&quot;&quot;) &gt; 0 &amp;&amp;amp; line(&quot;&#039;\&quot;&quot;) &lt;= line(&quot;$&quot;)&lt;br /&gt;
    \| exe &quot;normal! g&#039;\&quot;&quot; | endif&lt;br /&gt;
endif&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&#039;自动识别文件类型&lt;br /&gt;
if has(&quot;autocmd&quot;)&lt;br /&gt;
  filetype indent on&lt;br /&gt;
endif&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 
    </content:encoded>

    <pubDate>Fri, 20 Mar 2009 00:50:15 +0800</pubDate>
    <guid isPermaLink="false">http://www.luochunhui.com/index.php?/id/503</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license><category>linux</category>
<category>php</category>

</item>
<item>
    <title>PHP Quebec 2009 PHP全球聚会PPT</title>
    <link>http://www.luochunhui.com/index.php?/id/502</link>
            <category>技术</category>
    
    <comments>http://www.luochunhui.com/index.php?/id/502#comments</comments>
    <wfw:comment>http://www.luochunhui.com/wfwcomment.php?cid=502</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.luochunhui.com/rss.php?version=2.0&amp;type=comments&amp;cid=502</wfw:commentRss>
    

    <author>nospam@example.com (rollenc)</author>
    <content:encoded>
    PHP全球聚会在加拿大举行， 目前已经有一些PPT和文档出来了。 &lt;br /&gt;
先睹为快：&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://talks.somabo.de/200903_montreal_oop.pdf&quot;&gt;Objects for the Masses&lt;/a&gt;  &lt;/li&gt;
&lt;li&gt;&lt;i&gt;Marcus Borger&lt;/i&gt; - &lt;a href=&quot;http://talks.somabo.de/200903_montreal_worst_practice.pdf&quot;&gt;Worst PHP Practice&lt;/a&gt; 糟糕的PHP实践&lt;/li&gt;
&lt;li&gt;&lt;i&gt;Chris Hartjes&lt;/i&gt; - &lt;a href=&quot;http://chartjes-slides.s3.amazonaws.com/PHP%20Quebec%202009%20-%20Deployment%20talk.pdf&quot;&gt;Deployment is not a 4 Letter Word&lt;/a&gt; 部署并不是一句话就能搞定的问题&lt;/li&gt;
&lt;li&gt;&lt;i&gt;Fabien Potencier&lt;/i&gt; - &lt;a href=&quot;http://fabien.potencier.org/talk/22/phpquebec-2009-symfony-2&quot;&gt;Symfony 2&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;i&gt;Ilia Alshanetsky&lt;/i&gt; - &lt;a href=&quot;http://ilia.ws/files/phpquebec_2009.pdf&quot;&gt;Common optimization Mistakes&lt;/a&gt;PHP优化误区 优化可以先从硬件，系统， PHP扩展，数据库方面依次展开，而不仅仅只是优化PHP代码&lt;/li&gt;
&lt;li&gt;&lt;i&gt;Marcus Borger&lt;/i&gt; - &lt;a href=&quot;http://talks.somabo.de/200903_montreal_oop.pdf&quot;&gt;Objects for the Masses&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://talks.somabo.de/200903_montreal_php_extension_writing.pdf&quot;&gt;PHP Extension Writing&lt;/a&gt;,  PHP扩展编写&lt;/li&gt;
&lt;li&gt;&lt;i&gt;Stefan Priebsch&lt;/i&gt; - &lt;a href=&quot;http://www.slideshare.net/spriebsch/managing-the-software-lifecycle-of-php-applications?type=powerpoint&quot;&gt;Managing the Software Life Cycle of PHP Applications&lt;/a&gt; PHP软件开发的生命周期&lt;/li&gt;
&lt;/ul&gt;
 
    </content:encoded>

    <pubDate>Wed, 11 Mar 2009 05:25:58 +0800</pubDate>
    <guid isPermaLink="false">http://www.luochunhui.com/index.php?/id/502</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license><category>php</category>

</item>
<item>
    <title>Cache之Mysql, Memcached, File比较</title>
    <link>http://www.luochunhui.com/index.php?/id/496</link>
            <category>技术</category>
    
    <comments>http://www.luochunhui.com/index.php?/id/496#comments</comments>
    <wfw:comment>http://www.luochunhui.com/wfwcomment.php?cid=496</wfw:comment>

    <slash:comments>4</slash:comments>
    <wfw:commentRss>http://www.luochunhui.com/rss.php?version=2.0&amp;type=comments&amp;cid=496</wfw:commentRss>
    

    <author>nospam@example.com (rollenc)</author>
    <content:encoded>
    今天对几种缓存存储器进行了对比。发现最快的存储还是硬盘。当然，硬盘是很强悍的硬盘:  SAS 15K。&lt;br /&gt;
&lt;br /&gt;
对比数据：&lt;br /&gt;
&lt;br /&gt;
Mysql:5.8483519554138&lt;br /&gt;
Memcached: 2.5365290641785&lt;br /&gt;
File: 0.48778581619263&lt;br /&gt;
&lt;br /&gt;
测试环境：&lt;br /&gt;
Mysql5 局域网&lt;br /&gt;
Memcached 局域网&lt;br /&gt;
File 本机器&lt;br /&gt;
PHP5.1.6 测试代码使用PHP运行。均为原生函数 mysql_query, memcache_get, file_get_contents&lt;br /&gt;
&lt;br /&gt;
测试循环次数：&lt;br /&gt;
10K&lt;br /&gt;
&lt;br /&gt;
机器配置：
CPU 2.8x4&lt;br /&gt;
内存 8G&lt;br /&gt;
硬盘 SAS 15K&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
如果不需要考虑多服务器共享， 还是file cache来得方便来得快。&lt;br /&gt;

补上测试代码&lt;br /&gt;
测试代码如下，头部有mysql和memcache的连接工作，略去。&lt;br /&gt;

&lt;pre name=&quot;code&quot; class=&quot;php&quot;&gt;
        echo &quot;Mysql Primary:&quot;;
        $startTime = microtime(1);
        
        for($i=0; $i&lt;10000; $i++) {
                $result = mysql_query(&quot;select * from Cache Where ID = &quot;.$i);
                $thread = mysql_fetch_row($result);
        }
        echo microtime(true) - $startTime;
        
        echo &quot;\n&quot;;
        
        echo &quot;Memcached: &quot;;
        
        $startTime = microtime(1);
        for($i=0;$i&lt;10000;$i++) {
        if(! $thread = memcache_get($memcache_obj, &#039;sdfsdafsdaf&#039;.$i)) {
        //echo &#039;Nerver got here&#039;;
        $result = mysql_query(&quot;select * from Cache Where ID = &quot;.$i);
        $thread = mysql_fetch_row($result);
        if($thread == null) {
        $thread = &#039;Missing&#039;;
        }
        memcache_set($memcache_obj, &#039;sdfsdafsdaf&#039;.$i, $thread, null, 30);
        }
        }
        echo microtime(true) - $startTime;
        
        echo &quot;\n&quot;;
        
        echo &quot;File: &quot;;
        $startTime = microtime(1);
        for($i=0;$i&lt;10000;$i++) {
                if(! $thread = unserialize(file_get_contents(&#039;cache/&#039;.&#039;sdfsdafsdaf&#039;.$i . &#039;.cache&#039;))) {
                        //echo &#039;Nerver got here&#039;;
                        $result = mysql_query(&quot;select * from Cache Where ID = &quot;.$i);
                        $thread = mysql_fetch_row($result);
                        if($thread == null) {
                                $thread = &#039;Missing&#039;;
                        }
                        file_put_contents(&#039;cache/&#039;.&#039;sdfsdafsdaf&#039;.$i . &#039;.cache&#039;, serialize($thread));
                }
        }
        
        
        echo microtime(true) - $startTime;
        
        echo &quot;\n&quot;;
&lt;/pre&gt;


 
    </content:encoded>

    <pubDate>Wed, 11 Feb 2009 07:31:54 +0800</pubDate>
    <guid isPermaLink="false">http://www.luochunhui.com/index.php?/id/496</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license><category>Cache</category>
<category>Memcached</category>

</item>
<item>
    <title>Nginx代理服务器</title>
    <link>http://www.luochunhui.com/index.php?/id/484</link>
            <category>技术</category>
    
    <comments>http://www.luochunhui.com/index.php?/id/484#comments</comments>
    <wfw:comment>http://www.luochunhui.com/wfwcomment.php?cid=484</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.luochunhui.com/rss.php?version=2.0&amp;type=comments&amp;cid=484</wfw:commentRss>
    

    <author>nospam@example.com (rollenc)</author>
    <content:encoded>
    我的本博客由&lt;a href=&quot;http://www.dreamhost.com/r.cgi?237000&quot;&gt;Dreamhost&lt;/a&gt;提供空间. 但部分教育网同学无法访问到或速度极慢.于是产生了一个使用Nginx建立代理服务器 &lt;a href=&quot;http://cn.luochunhui.com&quot;&gt;cn.luochunhui.com&lt;/a&gt;的想法&lt;br /&gt;
&lt;br /&gt;
设置原理:&lt;br /&gt;
  用户访问cn.luochunhui.com(上海S1) =&gt; S1访问www.luochunhui.com(美国S2) =&gt; S2返回内容给S1 =&gt; S1返回内容给用户.&lt;br /&gt;
&lt;br /&gt;
设置方法:&lt;br /&gt;
增加Nginx配置文件:&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;bash&quot;&gt;&lt;br /&gt;
#file: /etc/nginx/sites-enabled/cn.luochunhui.com &lt;br /&gt;
server {&lt;br /&gt;
	listen   80;&lt;br /&gt;
	server_name  cn.luochunhui.com;&lt;br /&gt;
&lt;br /&gt;
	access_log  /var/www/logs/cn.luochunhui.com_access.log;&lt;br /&gt;
&lt;br /&gt;
	location /robots.txt {&lt;br /&gt;
		root   /home/rollenc/luochunhui.com;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	location / {&lt;br /&gt;
  		proxy_pass http://www.luochunhui.com;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
其中有一段 关于 robots.txt 的设置. 是关于SEO方面的. 在代理服务器上设置了一个 robots文件, 告诉蜘蛛别爬cn域.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 
    </content:encoded>

    <pubDate>Thu, 08 Jan 2009 14:30:20 +0800</pubDate>
    <guid isPermaLink="false">http://www.luochunhui.com/index.php?/id/484</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license><category>nginx</category>

</item>

</channel>
</rss>