<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    kelefa  
    大千世界中,唯一缺乏的就是人類的注意力。
    日歷
    <2006年7月>
    2526272829301
    2345678
    9101112131415
    16171819202122
    23242526272829
    303112345
    統計
    • 隨筆 - 11
    • 文章 - 0
    • 評論 - 28
    • 引用 - 0

    導航

    常用鏈接

    留言簿(2)

    隨筆分類

    隨筆檔案

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

     

    OSCache是OpenSymphony組織提供的一個J2EE架構中Web應用層的緩存技術實現方案,可以使用內存、硬盤空間、同時使用內存和硬盤作為緩存區靈活的緩存系統:OSCache支持多種緩存級別,使用相當靈活簡單,在jsp中刷新緩存只要兩行代碼:


    <% @?taglib?uri = " oscache " ?prefix = " cache " %>

    < cache:flush?group = " device_types " ?scope = " application " ? />

    但是有時需要在java代碼中刷新緩存,以下這個OSCacheUtil類可以工作,但是只能在webwork環境內調用:
    import?javax.servlet.jsp.PageContext;

    import?org.apache.log4j.Logger;
    import?com.opensymphony.oscache.base.Cache;
    import?com.opensymphony.oscache.web.ServletCacheAdministrator;
    import?com.opensymphony.webwork.ServletActionContext;

    /**
    ?*?osCache緩存工具類.
    ?*?只能在webwork環境內調用
    ?*
    ?*?<p>Copyright:?Copyright?(c)?2005</p>
    ?*?<p>Company:?</p>
    ?*?
    @author?楊杰榮
    ?*?
    @version?1.0
    ?
    */

    public?class?OSCacheUtil
    {
    ??
    private?static?final?Logger?log?=?Logger.getLogger(?OSCacheUtil.class?);

    ??
    public?static?final?int?ALL_SCOPE?=?0;
    ??
    public?static?final?int?SESSION_SCOPE?=?PageContext.SESSION_SCOPE;
    ??
    public?static?final?int?APPLICATION_SCOPE?=?PageContext.APPLICATION_SCOPE;

    ??
    private?static?ServletCacheAdministrator?admin?=?null;

    ??
    private?OSCacheUtil()
    ??
    {
    ??}


    ??
    /**
    ???*?刷新osCache組
    ???*?
    @param?group?Cache組名
    ???*?
    @param?cacheScope?Cache范圍,只能是SESSION_SCOPE或APPLICATION_SCOPE
    ???
    */

    ??
    public?static?void?flushGroup(?String?group,?int?cacheScope?)
    ??
    {
    ????initCacheAdmin();

    ????
    if?(?cacheScope?==?SESSION_SCOPE?||?cacheScope?==?APPLICATION_SCOPE?)
    ????
    {
    ??????Cache?cache?
    =?admin.getCache(?ServletActionContext.getRequest(),
    ????????????????????????????????????cacheScope?);
    ??????cache.flushGroup(?group?);
    ????}

    ????
    else
    ????
    {
    ??????log.warn(?
    "A?cache?group?was?specified?for?flushing,?but?the?scope?wasn't?supplied?or?was?invalid"?);
    ????}

    ??}


    ??
    /**
    ???*?刷新osCache中的某個key'
    ???*?
    @param?key?String
    ???*?
    @param?cacheScope?Cache范圍,只能是SESSION_SCOPE或APPLICATION_SCOPE
    ???
    */

    ??
    public?static?void?flushKey(?String?key,?int?cacheScope?)
    ??
    {
    ????initCacheAdmin();

    ????
    if?(?cacheScope?==?SESSION_SCOPE?||?cacheScope?==?APPLICATION_SCOPE?)
    ????
    {
    ??????String?actualKey?
    =?admin.generateEntryKey(
    ??????????key,?ServletActionContext.getRequest(),?cacheScope,?
    null?);

    ??????Cache?cache?
    =?admin.getCache(?ServletActionContext.getRequest(),?cacheScope?);
    ??????cache.flushEntry(?actualKey?);
    ????}

    ????
    else
    ????
    {
    ??????log.warn(?
    "A?cache?key?was?specified?for?flushing,?but?the?scope?wasn't?supplied?or?was?invalid"?);
    ????}

    ??}


    ??
    /**
    ???*?刷新所有的osCache
    ???*?
    @param?cacheScope?Cache范圍,可以是SESSION_SCOPE,APPLICATION_SCOPE,ALL_SCOPE
    ???
    */

    ??
    public?static?void?flushAll(?int?cacheScope?)
    ??
    {
    ????initCacheAdmin();

    ????
    if?(?cacheScope?==?SESSION_SCOPE?||?cacheScope?==?APPLICATION_SCOPE?)
    ????
    {
    ??????admin.setFlushTime(?cacheScope?);
    ????}

    ????
    else
    ????
    {
    ??????admin.flushAll();
    ????}

    ??}



    ??
    private?static?void?initCacheAdmin()
    ??
    {
    ????
    if?(?admin?==?null?)
    ????
    {
    ??????admin?
    =?ServletCacheAdministrator.getInstance(?ServletActionContext.
    ??????????getServletContext()?);
    ????}

    ??}

    }
    posted on 2006-06-29 09:32 楊杰榮 閱讀(1488) 評論(2)  編輯  收藏 所屬分類: 開源應用
    評論:
    • # re: OSCache工具類  pandaxiaoxi Posted @ 2006-07-02 21:36
      問個跟本主題無關的問題,你是怎么在blog上發代碼的,代碼怎么跟在ide里一樣那?看起來很工整,能交交我嗎?呵呵  回復  更多評論   

    • # re: OSCache工具類  楊杰榮 Posted @ 2006-07-03 13:15
      @pandaxiaoxi

      點擊“代碼”圖標,然后粘貼代碼就ok了  回復  更多評論   

     
    Copyright © 楊杰榮 Powered by: 博客園 模板提供:滬江博客
    主站蜘蛛池模板: 男男黄GAY片免费网站WWW | 毛片无码免费无码播放 | 免费吃奶摸下激烈视频| 亚洲砖码砖专无区2023| 成人啪精品视频免费网站| 亚洲日韩一中文字暮| 日韩精品视频免费观看| 337P日本欧洲亚洲大胆艺术图| 免费高清小黄站在线观看| 亚洲AV噜噜一区二区三区| 全黄性性激高免费视频| 日韩大片在线永久免费观看网站 | 久久aa毛片免费播放嗯啊| 18gay台湾男同亚洲男同| 成人免费AA片在线观看| 100部毛片免费全部播放完整| 久久av无码专区亚洲av桃花岛| 2021国产精品成人免费视频| 亚洲人成片在线观看| 国产成人精品免费视频大全五级| 国产亚洲视频在线观看| 亚洲自偷自偷在线制服| 91成人在线免费观看| 亚洲一卡2卡三卡4卡无卡下载| 国产午夜鲁丝片AV无码免费 | 亚洲国产精品自在在线观看| 免费专区丝袜脚调教视频| 亚洲精品无码久久久久APP| www.亚洲色图.com| 午夜视频在线免费观看| 亚洲一区二区三区在线观看网站 | 亚洲网站免费观看| 韩国亚洲伊人久久综合影院| 亚洲成色在线综合网站| 成年私人影院免费视频网站| 一级白嫩美女毛片免费| 亚洲日产2021三区在线| 国产亚洲欧洲Aⅴ综合一区 | 四虎永久在线观看免费网站网址| 黄色免费网站在线看| 亚洲精品高清久久|