フォトアルバム

2011年10月

            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          

なかのひと

373news.com

google Search

  • Google
    blog.ganymean.org
    WWW

Google Analytics

« Model-Glue DTD | メイン | Model-Glue DTD#2 »

Model-Glue Viewデータのキャッシング

topica.comのModel-GlueのMLで、'Caching Content in MG'というタイトルでコンテンツのキャッシングに関するスレッドが立った。

解決方法は、ズバリ・・・
ModelGlue.Core.controller.cfc内のGetFromCache

ModelGlue.Util.TimedCache.cfc内のItemNotFound

ModelGlue.Core.controller.cfc内のAddToCache
を使う。つまり、
1.キャッシュしたいコンテンツ<"news">を定義し、
 <cftry>

   <cfset news =GetFromCache("news") />
2.次に、キャッシュの有無をチェックし、
   <cfcatch type="ModelGlue.Util.TimedCache.ItemNotFound">
3.例外が生じた場合、特定の処理を実施し、キャッシュに追加

     something query
     <cfset addToCache("news", news) />

       <cfcache />

  </cftry>

するようだ。

<cffunction name="GetNews" access="Public" returnType="void"
output="false" hint="I am an event handler.">
  <cfargument name="event" type="ModelGlue.Core.Event" required="true">

  <cfset var news = "" />

  <cftry>
    <!--- Try to get it from the cache --->
    <cfset news = getFromCache("news") />
    <!--- If it's not in the cache --->
    <cfcatch type="ModelGlue.Util.TimedCache.ItemNotFound">
      <cfquery datasource="foo" name="news">
        SELECT newsId, title FROM news
      </cfquery>
      <cfset addToCache("news", news) />
    </cfcatch>
  </cftry>

  <cfset arguments.event.setValue("news", news) />
</cffunction>

うーん、やはりModelGlueの内部をもう少し学ぶ必要がありそうだなあー。



 

トラックバック

このページのトラックバックURL:
http://app.synapse-blog.jp/t/trackback/190195/5976813

Model-Glue Viewデータのキャッシングを参照しているブログ:

コメント

コメントを投稿

コメントは記事の投稿者が承認するまで表示されません。

ログイン

  • コントロールパネルへのログイン
    アカウント:

    パスワード:

更新ブログ

最近のトラックバック

Google

ブログ powered by TypePad
Member since 04/2005