为 Merb 框架提供缓存支持 Merb_piece_cache

jopen 13年前
     <p>Merb_piece_cache 是一个小型的Ruby库,用以提供给 Merb 框架来缓存 HTML 片段。</p>    <div id="p_fullcontent" class="detail">     <p><a style="font-weight:bold;" href="/misc/goto?guid=4958185340059188796" target="_blank">Merb</a>是基于Ruby语言的MVC WEB开发框架</p>     <p>从 Rubyforge 上安装 Merb 运行: <span style="font-family:-webkit-monospace;">gem install merb</span></p>     <p>也可以从 Merb 的 "edge" repository 获得:</p>     <p><span style="font-family:-webkit-monospace;">gem install merb --source http://edge.merbivore.com</span></p>    </div>    <p>示例代码:</p>    <pre class="brush:ruby; toolbar: true; auto-links: false;">  <!-- rendered every time (because never cached) -->     <% if @user %>       Hello <%=h @user %>!     <% else %>       <a href="/login">Login</a>     <% end %>      <!-- rendered only when cache is expired or not found -->     <% lifetime = 5*60  # sec, default is nil(=infinity) %>     <% cache_with("members/index", lifetime) do %>       <ul>       <% for member in @members %>         <li><%=h @member.name %></li>       <% end %>       <ul>     <% end %></pre>    <p></p>    <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1324812734108" target="_blank">http://www.open-open.com/lib/view/home/1324812734108</a></p>