﻿<?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>语源科技BlogJava-JavaVM</title><link>http://www.blogjava.net/JavaVM/</link><description>不闻不若闻之，闻之不若见之。&lt;BR&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
见之不若知之，知之不若行之。</description><language>zh-cn</language><lastBuildDate>Sat, 18 Apr 2026 11:09:09 GMT</lastBuildDate><pubDate>Sat, 18 Apr 2026 11:09:09 GMT</pubDate><ttl>60</ttl><item><title>Unison使用文档</title><link>http://www.blogjava.net/JavaVM/archive/2007/12/28/171114.html</link><dc:creator>JavaVM</dc:creator><author>JavaVM</author><pubDate>Fri, 28 Dec 2007 03:08:00 GMT</pubDate><guid>http://www.blogjava.net/JavaVM/archive/2007/12/28/171114.html</guid><wfw:comment>http://www.blogjava.net/JavaVM/comments/171114.html</wfw:comment><comments>http://www.blogjava.net/JavaVM/archive/2007/12/28/171114.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/JavaVM/comments/commentRss/171114.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/JavaVM/services/trackbacks/171114.html</trackback:ping><description><![CDATA[<div class="t_msgfont" id="postmessage_223847">一:Unison简介<br />
<br />
Unison是<span class="t_tag" onclick="tagshow(event)" href="tag.php?name=windows">windows</span>和unix平台下都可以使用的文件同步工具，它能使两个文件夹（本地或网络上的）保持内容的一致。unison拥有其它一些同步工具或<span class="t_tag" onclick="tagshow(event)" href="tag.php?name=%CE%C4%BC%FE">文件</span><span class="t_tag" onclick="tagshow(event)" href="tag.php?name=%CF%B5%CD%B3">系统</span>的相同特性，但也有自己的特点：<br />
&nbsp; &nbsp;&nbsp; &nbsp;跨平台使用；<br />
&nbsp; &nbsp;&nbsp; &nbsp;对内核和<span class="t_tag" onclick="tagshow(event)" href="tag.php?name=%D3%C3%BB%A7">用户</span>权限没有特别要求；<br />
&nbsp; &nbsp;&nbsp; &nbsp;unison是双向的，它能自动处理两分拷贝中更新没有冲突的部分，有冲突的部分将会显示出来让用户选择更新策略；<br />
&nbsp; &nbsp;&nbsp; &nbsp;只要是能连通的两台主机，就可以运行unison，可以直接使用socket连接或安全的ssh连接方式，对带宽的要求不高，使用类似rsync的压缩传输<span class="t_tag" onclick="tagshow(event)" href="tag.php?name=%D0%AD%D2%E9">协议</span>。<br />
Unison有文字界面和图形界面，这里只介绍如何在文字界面下使用.<br />
<br />
二:安装unison<br />
<br />
unison各种版本<span class="t_tag" onclick="tagshow(event)" href="tag.php?name=%CF%C2%D4%D8">下载</span>地址：<br />
<a href="http://www.seas.upenn.edu/~bcpierce/unison//download.html" target="_blank"><font color="#095c83">http://www.seas.upenn.edu/~bcpierce/unison//download.html</font></a><br />
unison编译器下载地址：<br />
<a href="http://caml.inria.fr/pub/distrib/ocaml-3.10" target="_blank"><font color="#095c83">http://caml.inria.fr/pub/distrib/ocaml-3.10</font></a><br />
其它有用链接；<br />
<a href="http://worldhello.net/doc/bcp/unison.html" target="_blank"><font color="#095c83">http://worldhello.net/doc/bcp/unison.html</font></a><br />
<a href="http://www.seas.upenn.edu/~bcpierce/unison//contrib.html" target="_blank"><font color="#095c83">http://www.seas.upenn.edu/~bcpierce/unison//contrib.html</font></a><br />
<a href="http://www.cis.upenn.edu/~bcpierce/unison/download/releases/stable/unison-manual.html#rshmeth" target="_blank"><font color="#095c83">http://www.cis.upenn.edu/~bcpierce/unison/download/releases/stable/unison-manual.html#rshmeth</font></a><br />
<a href="http://linux.chinaunix.net/bbs/viewthread.php?tid=888250&amp;extra=page%3D1%26amp%3Bfilter%3Dreward" target="_blank"><font color="#095c83">http://linux.<span class="t_tag" onclick="tagshow(event)" href="tag.php?name=china">china</span>unix.net/bbs/viewthread.php?tid=888250&amp;extra=page%3D1%26amp%3Bfilter%3Dreward</font></a><br />
从以上地址可以下载各种平台,各种版本的unison,有基于源码安装的,有二进制的,我下载的是二进制的,可以直接使用.这里介绍源码安装:<br />
源码安装unison<br />
Linux下从源码包编译安装，需要一个叫做Objective Caml compiler的工具，版本至少3.0.7，可以从这里下载：<a href="http://caml.inria.fr/" target="_blank"><font color="#095c83">http://caml.inria.fr/</font></a><br />
Ocaml安装脚本如下：<br />
# tar -zxf ocaml-3.09.3.tar.gz<br />
# cd ocaml-3.09.3<br />
# ./configure<br />
# make world opt<br />
# make install<br />
Unison对版本要求很高，进行同步的两台主机需要相同版本的unison，所以这里使用和windows一致的版本2.13.16，unison-2.13.16.tar.gz<br />
安装脚本如下：<br />
# tar -zxf unison-2.13.16.tar.gz<br />
# cd unison-2.13.16<br />
# make UISTYLE=text<br />
# make install<br />
之后将生成可执行文件unison，将其cp到系统PATH即可。<br />
# cp ./unison /usr/local/bin<br />
<br />
三:配置双机ssh信任<br />
<br />
由于unison在远程同步文件夹要登陆远程<span class="t_tag" onclick="tagshow(event)" href="tag.php?name=%B7%FE%CE%F1%C6%F7">服务器</span>,因此要配置两机互相信任<br />
本例假设本地机为：10.178.1.132(linux)<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 远程机：10.178.1.110(solaris)<br />
1.&nbsp; &nbsp;在两台机器上创建 RSA密钥 <br />
以下操作要在本地机和远程机上都执行一遍<br />
&nbsp; &nbsp;（1）以 root 用户<span class="t_tag" onclick="tagshow(event)" href="tag.php?name=%B5%C7%C2%BC">登录</span> <br />
&nbsp; &nbsp;（2）在 root 用户的 主目录内创建.ssh 目录并设置正确的权限 <br />
&nbsp; &nbsp;[root@gsgatzhapp1 ~]# mkdir ~/.ssh <br />
&nbsp; &nbsp;[root@gsgatzhapp1 ~]# chmod 700 ~/.ssh <br />
&nbsp;&nbsp;（3）使用 ssh-keygen 命令生成第 2 版本的 SSH 协议的 RSA 密钥 <br />
&nbsp; &nbsp;[root@gsgatzhapp1 ~]# ssh-keygen -t rsa <br />
&nbsp; &nbsp;Generating public/private rsa key pair. <br />
&nbsp; &nbsp;Enter file in which to save the key (/root/.ssh/id_rsa): <br />
&nbsp; &nbsp;Enter passphrase (empty for no passphrase): <br />
&nbsp; &nbsp;Enter same passphrase again: <br />
&nbsp; &nbsp;Your identification has been saved in /root/.ssh/id_rsa. <br />
&nbsp; &nbsp;Your public key has been saved in /root/.ssh/id_rsa.pub. <br />
&nbsp; &nbsp;The key fingerprint is: <br />
&nbsp; &nbsp;17:e4:7c:79:8d:a0:00:3b:d9:f7:7a:56:f3:ac:54:4d [e<span class="t_tag" onclick="tagshow(event)" href="tag.php?name=mail">mail</span>=oracle@gsgatzhapp1]<font color="#095c83">oracle@gsgatzhapp1</font>[/email] <br />
&nbsp; &nbsp;在提示保存私钥（key）和公钥（public key）的位置时，使用默认值。 如果需要私钥密码（passphrase），则输入一个私钥密码（如果使用私钥密码，使用 ssh 执行远程命令时需要输入私钥密码，因此，本案例中未使用私钥密码），因此，直接回车即可。 <br />
&nbsp; &nbsp;2. 添加密钥到授权密钥文件（authorized key file）中 <br />
&nbsp; &nbsp;&nbsp;&nbsp;（1）以 root 用户登录 <br />
&nbsp; &nbsp;&nbsp;&nbsp;（2）在本地机上执行 <br />
&nbsp; &nbsp;&nbsp;&nbsp;[root@gsgatzhapp1 ~] # cd ~/.ssh <br />
&nbsp; &nbsp;&nbsp;&nbsp;[<a href="mailto:root@gsgatzhapp1.ssh">root@gsgatzhapp1.ssh</a>]#ssh 10.178.1.132 cat /root/.ssh/id_rsa.pub &gt;&gt; authorized_keys <br />
&nbsp; &nbsp;&nbsp;&nbsp;[<a href="mailto:oracle@gsgatzhapp1.ssh">oracle@gsgatzhapp1.ssh</a>]#ssh 10.178.1.110 cat /root/.ssh/id_rsa.pub &gt;&gt; authorized_keys <br />
&nbsp; &nbsp;&nbsp;&nbsp;[<a href="mailto:oracle@gsgatzhapp1.ssh">oracle@gsgatzhapp1.ssh</a>]#scp authorized_keys 10.178.1.110:/root/.ssh/ <br />
[oracle@gsgatzhapp1 .ssh]# chmod 600&nbsp;&nbsp;/root/.ssh/authorized_keys <br />
（3）在远程机10.178.1.110 上： <br />
bash-2.05# chmod 600&nbsp;&nbsp;/root/.ssh/authorized_keys <br />
&nbsp; &nbsp; （4）测试 <br />
&nbsp; &nbsp;&nbsp;&nbsp;完成后，在 gsgatzhapp1 上执行： <br />
&nbsp; &nbsp;&nbsp;&nbsp;[root@gsgatzhapp1 ~]# ssh 10.178.1.132&nbsp;&nbsp;date <br />
&nbsp; &nbsp;&nbsp;&nbsp;[root@gsgatzhapp1 ~]#ssh 10.178.1.110 date <br />
&nbsp; &nbsp;&nbsp;&nbsp;如果不需要输入密码就出现系统日期，说明 SSH 配置成功。<br />
<br />
<h2>Unison使用文档（下）</h2>
<div class="t_msgfont" id="postmessage_223848">四:unison的使用<br />
Unison可以在一台主机上使用，同步两个文件夹，也可以在网络上是用。<br />
1:本地使用<br />
使用方法：<br />
#unison&nbsp;&nbsp;111 222&nbsp;&nbsp;#同步本地的111和222文件夹<br />
Contacting server...<br />
Looking for changes<br />
Warning: No archive files were found for these roots.&nbsp;&nbsp;This can happen either<br />
because this is the first time you have synchronized these roots, <br />
or because you have upgraded Unison to a new version with a different<br />
archive format.&nbsp;&nbsp;<br />
Update detection may take a while on this run if the replicas are <br />
large.<br />
Unison will assume that the 'last synchronized state' of both replicas<br />
was completely empty.&nbsp;&nbsp;This means that any files that are different<br />
will be reported as conflicts, and any files that exist only on one<br />
replica will be judged as new and propagated to the other replica.<br />
If the two replicas are identical, then no changes will be reported.<br />
Press return to continue.[&lt;spc&gt;] Reconciling changes<br />
111&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 222&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;---- file&nbsp; &nbsp;&nbsp; &nbsp; aaaaaaaaaaaaa&nbsp;&nbsp;[f] ?<br />
Commands:<br />
&nbsp;&nbsp;&lt;ret&gt; or f or &lt;spc&gt;&nbsp; &nbsp;follow unison's recommendation (if any)<br />
&nbsp;&nbsp;I&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;ignore this path permanently<br />
&nbsp;&nbsp;E&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;permanently ignore files with this extension<br />
&nbsp;&nbsp;N&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;permanently ignore paths ending with this name<br />
&nbsp;&nbsp;m&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;merge the versions<br />
&nbsp;&nbsp;d&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;show differences<br />
&nbsp;&nbsp;x&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;show details<br />
&nbsp;&nbsp;l&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;list all suggested changes<br />
&nbsp;&nbsp;p or b&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; go back to previous item<br />
&nbsp;&nbsp;g&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;proceed immediately to propagating changes<br />
&nbsp;&nbsp;q&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;exit unison without propagating any changes<br />
&nbsp;&nbsp;/&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;skip<br />
&nbsp;&nbsp;&gt; or .&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; propagate from left to right<br />
&nbsp;&nbsp;&lt; or ,&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; propagate from right to left<br />
<br />
&lt;---- file&nbsp; &nbsp;&nbsp; &nbsp; aaaaaaaaaaaaa&nbsp;&nbsp;[f] f<br />
<br />
Proceed with propagating updates? [] y<br />
Propagating updates<br />
<br />
UNISON started propagating changes at 15:06:08 on 27 Aug 2007<br />
[BGN] Copying aaaaaaaaaaaaa<br />
&nbsp;&nbsp;from /222<br />
&nbsp;&nbsp;to /111<br />
[END] Copying aaaaaaaaaaaaa<br />
UNISON finished propagating changes at 15:06:08 on 27 Aug 2007<br />
Saving synchronizer state<br />
Synchronization complete&nbsp;&nbsp;(1 item transferred, 0 skipped, 0 failures)<br />
如果检测到两个文件夹有所不同，unison会提示，让你选择相应的操作。如上例所示.<br />
表示右边222的文件夹有新的文件，是否同步到左边的111文件夹，f表示force，然后将确认,进行更新,如果输入？会有更详细的介绍。<br />
2: unison远程使用<br />
使用方法：<br />
# unison &lt;本地目录&gt; ssh://remotehostname(IP)/&lt;远程目录的绝对路径&gt;<br />
例如:<br />
# unison /home/AAA ssh://username@remotehostname(ip)//DB/path/BBB<br />
表示将本机的目录/home/AAA和远端主机的/DB/path/BBB进行同步。一般的，需要两台机能ssh连接。<br />
注意 在主机和目录间又多加了一个 "/"<br />
3:unison参数说明<br />
Unison有很多参数,这里只介绍经常使用的几个,详细的请参看unison手册:<br />
"&nbsp; &nbsp;&nbsp;&nbsp;-testserver <br />
测试连通性，连接到服务器即退出。示例: <br />
$ unison / ssh://opensou1@bluehost/&nbsp; &nbsp; -servercmd=~/bin/unison -testserver<br />
如果服务器端 unison 可执行文件不在默认目录下，甚至没有 unison 命令（需要你编译一个上传到服务器），则需要使用 -servercmd 参数告诉要执行的服务器 unison 命令位置。 <br />
使用 -testserver 参数，则成功链接即退出，也不会去执行目录的比较等后续操作。 <br />
"&nbsp; &nbsp;&nbsp;&nbsp;-servercmd xxx <br />
告诉 unison， 服务器端的 unison 命令是什么。参见上面的示例。 <br />
"&nbsp; &nbsp;&nbsp;&nbsp;-auto <br />
接受缺省的动作，然后等待用户确认是否执行。 <br />
"&nbsp; &nbsp;&nbsp;&nbsp;-batch <br />
batch mode, 全自动模式，接受缺省动作，并执行。 <br />
"&nbsp; &nbsp;&nbsp;&nbsp;-ignore xxx <br />
增加 xxx 到忽略列表中 <br />
"&nbsp; &nbsp;&nbsp;&nbsp;-ignorecase [true|false|default] <br />
是否忽略文件名大小写 <br />
"&nbsp; &nbsp;&nbsp;&nbsp;-follow xxx <br />
是否支持对符号连接指向内容的同步<br />
"&nbsp; &nbsp;&nbsp;&nbsp;owner = true (保持同步过来的文件属主)<br />
"&nbsp; &nbsp;&nbsp;&nbsp;group = true (保持同步过来的文件组信息)<br />
"&nbsp; &nbsp;&nbsp;&nbsp;perms = -1&nbsp; &nbsp;(保持同步过来的文件读写权限)<br />
"&nbsp; &nbsp;&nbsp;&nbsp;repeat = 1&nbsp; &nbsp;(间隔1秒后,开始新的一次同步检查)<br />
"&nbsp; &nbsp;&nbsp;&nbsp;retry = 3&nbsp; &nbsp; (失败重试)<br />
"&nbsp; &nbsp;&nbsp;&nbsp;sshargs = -C (使用ssh的压缩传输方式)<br />
"&nbsp; &nbsp;&nbsp;&nbsp;xferbycopying = true<br />
<br />
"&nbsp; &nbsp;&nbsp;&nbsp;-immutable xxx <br />
不变目录，扫描时可以忽略 <br />
"&nbsp; &nbsp;&nbsp;&nbsp;-silent <br />
安静模式 <br />
"&nbsp; &nbsp;&nbsp;&nbsp;-times <br />
同步修改时间 <br />
"&nbsp; &nbsp;&nbsp;&nbsp;-path xxx 参数 <br />
只同步 -path 参数指定的子目录以及文件，而非整个目录。-path 可以多次出现,例如 <br />
&nbsp;&nbsp;unison /home/username ssh://remotehost//home/username \<br />
&nbsp; &nbsp;&nbsp; &nbsp;-path shared \<br />
&nbsp; &nbsp;&nbsp; &nbsp;-path pub \<br />
&nbsp; &nbsp;&nbsp; &nbsp;-path .netscape/bookmarks.html<br />
4:通过配置文件来使用unison<br />
尽管可以完全通过命令行的方式来指定unison运行所需要的参数，但我们还是推荐使用配置文件来进行配置使用unison，原因很简单，看配置文件比看命令行容易理解，而且可管理性更强。<br />
默认的配置文件夹位于~currentuser/.unison，即当前用户的home目录下，windows则位于C:\Documents and Settings\currentuser\.unison，默认的配置文件名是default.prf.<br />
运行这样的命令:<br />
#unison exitgogo<br />
Unison将默认读取~currentuser/.unison/exitgogo.prf文件里的配置信息.我的配置信息在/root/.unison/exitgogo.prf,因此我们可以根据上面参数的介绍,把所有的参数配置信息写入到一个.prf的文件中.<br />
下面是我的一个web应用中两个文件夹同步的配置信息:<br />
root = /sina/webdata<br />
root = ssh://root@192.168.60.121//sina/webdata<br />
#force =/sina/webdata<br />
ignore = Path as/*<br />
#prefer = ssh://root@192.168.60.121//sina/webdata<br />
batch = true<br />
#repeat = 1<br />
#retry = 3<br />
owner = true<br />
group = true<br />
perms = -1<br />
fastcheck=false<br />
rsync =false<br />
#debug=verbose<br />
sshargs = -C<br />
xferbycopying = true<br />
log = true<br />
logfile = /root/.unison/sina_122.1547.log<br />
说明如下:<br />
两个root表示需要同步的文件夹<br />
force表示以本地的/var/www/bbsnew文件夹为标准，将该目录同步到远端。注意,如果指定了force参数,那么unison就变成了单项同步了,也就是说会以force指定的文件夹为准进行同步.<br />
Unison本身是可以双向同步的,但是要做到双向同步,就不要设置force参数,如果设置了force参数,就成了单项同步了,此时unison类似与sync.<br />
Unison双向同步基本原理是:假如有A B两个文件夹,A文件夹把自己的改动同步到B,B文件夹也把自己的改动同步到A,最后A B两文件夹的内容相同,是 A B文件夹的合集.<br />
Unison双向同步的一个缺点是,对于一个文件在两个同步文件夹中都被修改时,unison是不会去同步的,因为unison无法判断以那个为准.<br />
ignore = Path表示忽略/sina/webdata下面的WEB-INF/tmp目录,即同步时不同步它。<br />
batch = true,表示全自动模式，接受缺省动作，并执行<br />
-fastcheck&nbsp;&nbsp;true表示同步时使用文件的创建时间来比较两地文件，如果这个选项为false，unison则将比较两地文件的内容.建议设置为true<br />
log = true表示在终端输出运行信息。<br />
logfile则指定了同时将输出写入log文件。<br />
<br />
五:unison FAQ<br />
<br />
如何在和远程服务器同步大量数据，上传一部分数据后，超时：<br />
9%&nbsp;&nbsp;559:15 ETARead from remote host bluehost: Connection reset by peer<br />
Fatal error: Lost connection with the server<br />
实际操作中，最好的方法是,第一次先把要上传的文件打成包，用 ftp 上传，然后展开到服务器中，之后执行一次 unison 同步即可</div>
<br />
</div>
<img src ="http://www.blogjava.net/JavaVM/aggbug/171114.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JavaVM/" target="_blank">JavaVM</a> 2007-12-28 11:08 <a href="http://www.blogjava.net/JavaVM/archive/2007/12/28/171114.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转载] 几个著名java开源缓存系统的介绍 </title><link>http://www.blogjava.net/JavaVM/archive/2007/05/10/116472.html</link><dc:creator>JavaVM</dc:creator><author>JavaVM</author><pubDate>Thu, 10 May 2007 06:12:00 GMT</pubDate><guid>http://www.blogjava.net/JavaVM/archive/2007/05/10/116472.html</guid><wfw:comment>http://www.blogjava.net/JavaVM/comments/116472.html</wfw:comment><comments>http://www.blogjava.net/JavaVM/archive/2007/05/10/116472.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/JavaVM/comments/commentRss/116472.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/JavaVM/services/trackbacks/116472.html</trackback:ping><description><![CDATA[<div class=postText><span id=ArticleContent1_ArticleContent1_lblContent><strong><font color=#ff1493>OSCache<br></font></strong>OSCache是个一个广泛采用的高性能的J2EE缓存框架，OSCache能用于任何Java应用程序的普通的缓存解决方案。<br>OSCache有以下特点：<br>缓存任何对象，你可以不受限制的缓存部分jsp页面或HTTP请求，任何java对象都可以缓存。<br>拥有全面的API--OSCache API给你全面的程序来控制所有的OSCache特性。<br>永久缓存--缓存能随意的写入硬盘，因此允许昂贵的创建（expensive-to-create）数据来保持缓存，甚至能让应用重启。<br>支持集群--集群缓存数据能被单个的进行参数配置，不需要修改代码。<br>缓存记录的过期--你可以有最大限度的控制缓存对象的过期，包括可插入式的刷新策略（如果默认性能不需要时）。<br>官方网站 <a href="http://www.opensymphony.com/oscache/"><u><font color=#006ff7 size=2>http://www.opensymphony.com/oscache/</font></u></a> <br><br>
<p><font color=#ff1493><strong>Java Caching System<br></strong></font>JSC(Java Caching System)是一个用分布式的缓存系统，是基于服务器的java应用程序。它是通过提供管理各种动态缓存数据来加速动态web应用。<br>JCS和其他缓存系统一样，也是一个用于高速读取，低速写入的应用程序。<br>动态内容和报表系统能够获得更好的性能。<br>如果一个网站，有重复的网站结构，使用间歇性更新方式的数据库（而不是连续不断的更新数据库），被重复搜索出相同结果的，就能够通过执行缓存方式改进其性能和伸缩性。<br>官方网站 <a href="http://jakarta.apache.org/turbine/jcs/"><u><font color=#006ff7 size=2>http://jakarta.apache.org/turbine/jcs/</font></u></a></p>
<p><font color=#ff1493><strong>EHCache</strong></font><br>EHCache 是一个纯java的在进程中的缓存，它具有以下特性：快速，简单，为Hibernate2.1充当可插入的缓存，最小的依赖性，全面的文档和测试。</p>
<p>官方网站 <u><font color=#006ff7 size=2><a href="http://ehcache.sourceforge.net/">http://ehcache.sourceforge.net/</a></font></u></p>
<p><font color=#ff1493><strong>JCache</strong></font><br>JCache是个开源程序，正在努力成为JSR-107开源规范，JSR-107规范已经很多年没改变了。这个版本仍然是构建在最初的功能定义上。<br>官方网站 <a href="http://jcache.sourceforge.net/"><u><font color=#006ff7 size=2>http://jcache.sourceforge.net/<br><br></font></u></a></p>
<p><font color=#ff1493><strong>ShiftOne<br></strong></font>ShiftOne Java Object Cache是一个执行一系列严格的对象缓存策略的Java lib，就像一个轻量级的配置缓存工作状态的框架。<br>官方网站 <a href="http://jocache.sourceforge.net/"><u><font color=#006ff7 size=2>http://jocache.sourceforge.net/</font></u></a><br><br><strong><font color=#ff1493>SwarmCache<br></font></strong>SwarmCache是一个简单且有效的分布式缓存，它使用IP multicast与同一个局域网的其他主机进行通讯，是特别为集群和数据驱动web应用程序而设计的。SwarmCache能够让典型的读操作大大超过写操作的这类应用提供更好的性能支持。<br>SwarmCache使用JavaGroups来管理从属关系和分布式缓存的通讯。<br>官方网站 <a href="http://swarmcache.sourceforge.net/"><u><font color=#006ff7 size=2>http://swarmcache.sourceforge.net</font></u></a><br><br><font color=#ff1493><strong>TreeCache / JBossCache</strong></font><br>JBossCache是一个复制的事务处理缓存，它允许你缓存企业级应用数据来更好的改善性能。缓存数据被自动复制，让你轻松进行JBoss服务器之间的集群工作。JBossCache能够通过JBoss应用服务或其他J2EE容器来运行一个MBean服务，当然，它也能独立运行。<br>JBossCache包括两个模块：TreeCache和TreeCacheAOP。<br>TreeCache --是一个树形结构复制的事务处理缓存。<br>TreeCacheAOP --是一个&#8220;面向对象&#8221;缓存，它使用AOP来动态管理POJO(Plain Old Java Objects)<br>注：AOP是OOP的延续，是Aspect Oriented Programming的缩写，意思是面向方面编程。<br>官方网站 <a href="http://www.jboss.org/products/jbosscache"><u><font color=#006ff7 size=2>http://www.jboss.org/products/jbosscache<br></font></u></a></p>
<p><font color=#ff1493><strong>WhirlyCache</strong></font><br>Whirlycache是一个快速的、可配置的、存在于内存中的对象的缓存。它能够通过缓存对象来加快网站或应用程序的速度，否则就必须通过查询数据库或其他代价较高的处理程序来建立。<br>官方网站 <a href="https://whirlycache.dev.java.net/"><u><font color=#006ff7 size=2>https://whirlycache.dev.java.net/</font></u></a></p>
</span><br>
<div style="FONT-SIZE: 14px; LINE-HEIGHT: 25px"><strong>作者Blog：</strong><a id=ArticleContent1_ArticleContent1_AuthorBlogLink href="http://blog.csdn.net/creamsmallpig/" target=_blank><u><font color=#006ff7 size=2>http://blog.csdn.net/creamsmallpig/</font></u></a></div>
</div>
<img src ="http://www.blogjava.net/JavaVM/aggbug/116472.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JavaVM/" target="_blank">JavaVM</a> 2007-05-10 14:12 <a href="http://www.blogjava.net/JavaVM/archive/2007/05/10/116472.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>siteMesh的一个中文bug</title><link>http://www.blogjava.net/JavaVM/archive/2006/07/06/57053.html</link><dc:creator>JavaVM</dc:creator><author>JavaVM</author><pubDate>Thu, 06 Jul 2006 15:50:00 GMT</pubDate><guid>http://www.blogjava.net/JavaVM/archive/2006/07/06/57053.html</guid><wfw:comment>http://www.blogjava.net/JavaVM/comments/57053.html</wfw:comment><comments>http://www.blogjava.net/JavaVM/archive/2006/07/06/57053.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/JavaVM/comments/commentRss/57053.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/JavaVM/services/trackbacks/57053.html</trackback:ping><description><![CDATA[
		<font size="2">       经前同事介绍，前几天一直在试用siteMesh，在试用过程中发现一些不想被装饰的页面出现页面显示不全的问题。页面上出现一小段HTML标签。提示异常为java.lang.IllegalStateException 大致意思是试图写多少多少字节却只写入了多少多少字节。非常郁闷。看了源代码。发现应该是com.opensymphony.module.sitemesh.filter.PageFilter包里的<br /><br /><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"><span style="COLOR: #008080">1</span> <span style="COLOR: #000000">response.setContentLength(page.getContentLength()); </span></div></font>
		<br />
		<font size="2">没有考虑中文的情况。解决方案是将会出现的中文情况考虑进去。<br /><br /><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"><span style="COLOR: #008080">1</span> <span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> originalLength </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> page.getContentLength();</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">原来的长度</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080">2</span> <span style="COLOR: #008000"></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> bodyCNLenght </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> page.getBody().getBytes().length</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">page.getBody().length();</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">内容处理中文长度</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080">3</span> <span style="COLOR: #008000"></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> titleCNLength </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> page.getTitle().getBytes().length</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">page.getTitle().length();</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">title处理中文长度</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080">4</span> <span style="COLOR: #008000"></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> javascriptCNOfhead </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> page </span><span style="COLOR: #0000ff">instanceof</span><span style="COLOR: #000000"> FastPage</span><span style="COLOR: #000000">?</span><span style="COLOR: #000000">  ((FastPage)page).getHead().getBytes().length</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">((FastPage)page).getHead().length()):</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000"> ;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">head的长度，因为javascript中可能包括中文</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080">5</span> <span style="COLOR: #008000"></span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">6</span> <span style="COLOR: #000000">response.setContentLength(originalLength</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">bodyCNLenght</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">titleCNLength</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">javascriptCNOfhead);</span></div><br />这个解决方案是从网上搜索出来的，我想应该还有更好的解决方法。<br /><br /></font>
<img src ="http://www.blogjava.net/JavaVM/aggbug/57053.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JavaVM/" target="_blank">JavaVM</a> 2006-07-06 23:50 <a href="http://www.blogjava.net/JavaVM/archive/2006/07/06/57053.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>