三)mybatis 二級緩存,整合ehcache

mybatis-config.xml

<setting name="cacheEnabled" value="true" />

?

PersonMapper.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="cn.zno.smse.dao.PersonMapper" ><!--# mybatis ehcache 緩存配置 # ① 應該首先在配置文件中開啟緩存功能② 以下兩個 <cache> 標簽二選一,第一個可以輸出日志,第二個不輸出日志 。<cache type="org.mybatis.caches.ehcache.LoggingEhcache" /><cache type="org.mybatis.caches.ehcache.EhcacheCache"/> --><cache type="org.mybatis.caches.ehcache.LoggingEhcache" /><!--     省略代碼 -->
</mapper>

所處位置

<!ELEMENT mapper (cache-ref | cache | resultMap* | parameterMap* | sql* | insert* | update* | delete* | select* )+>

PersonMapper.xml 中禁用單個sql語句的緩存

useCache="false"

依賴

        <dependency><groupId>org.mybatis.caches</groupId><artifactId>mybatis-ehcache</artifactId><version>1.0.2</version></dependency>

?

日志?

初始化

-------------------------------------------------------------------
GMS: address=pc012-44159, cluster=EH_CACHE, physical address=172.16.162.238:14872
-------------------------------------------------------------------
2829 [localhost-startStop-1] INFO  n.s.e.d.j.JGroupsCacheManagerPeerProvider - JGroups Replication started for 'EH_CACHE'. JChannel: local_addr=pc012-44159
cluster_name=EH_CACHE
my_view=[pc012-44159|0] [pc012-44159]
connected=true
closed=false
discard_own_messages=true
state_transfer_supported=true
props=UDP(bind_addr=/172.16.162.238;oob_thread_pool_keep_alive_time=5000;timer_keep_alive_time=3000;external_port=0;oob_thread_pool_enabled=true;max_bundle_size=64000;diagnostics_ttl=8;receive_on_all_interfaces=false;mcast_port=45588;thread_pool_min_threads=2;thread_pool_keep_alive_time=5000;thread_pool_max_threads=8;enable_diagnostics=true;ucast_send_buf_size=640000;ip_ttl=8;oob_thread_pool_queue_max_size=100;enable_bundling=true;thread_pool_queue_enabled=true;timer_rejection_policy=run;diagnostics_port=7500;oob_thread_pool_max_threads=8;wheel_size=200;disable_loopback=false;logical_addr_cache_max_size=500;ip_mcast=true;tick_time=50;logical_addr_cache_expiration=120000;thread_pool_rejection_policy=discard;oob_thread_pool_min_threads=1;port_range=50;stats=true;mcast_send_buf_size=640000;id=21;mcast_recv_buf_size=25000000;diagnostics_addr=/224.0.75.75;bind_port=0;tos=8;oob_thread_pool_rejection_policy=Run;loopback=true;oob_thread_pool_queue_enabled=false;name=UDP;enable_unicast_bundling=false;thread_pool_enabled=true;thread_naming_pattern=cl;ucast_recv_buf_size=20000000;timer_max_threads=10;timer_queue_max_size=500;discard_incompatible_packets=true;ergonomics=true;bundler_capacity=200000;max_bundle_timeout=30;mcast_group_addr=/228.8.8.8;bind_interface_str=;timer_min_threads=4;log_discard_msgs=true;thread_pool_queue_max_size=10000;bundler_type=new;timer_type=new)
:PING(id=6;return_entire_cache=false;num_initial_members=20;break_on_coord_rsp=true;stagger_timeout=0;stats=true;name=PING;ergonomics=true;timeout=2000;num_initial_srv_members=0)
:MERGE2(id=0;stats=true;merge_fast=true;name=MERGE2;inconsistent_view_threshold=1;min_interval=10000;ergonomics=true;merge_fast_delay=1000;max_interval=30000)
:FD_SOCK(bind_addr=/172.16.162.238;external_port=0;port_range=50;stats=true;suspect_msg_interval=5000;client_bind_port=0;ergonomics=true;num_tries=3;id=3;get_cache_timeout=1000;sock_conn_timeout=1000;bind_interface_str=;name=FD_SOCK;keep_alive=true;start_port=0)
:FD_ALL(id=29;interval=3000;stats=true;name=FD_ALL;ergonomics=true;msg_counts_as_heartbeat=false;timeout=10000;timeout_check_interval=2000)
:VERIFY_SUSPECT(id=13;bind_addr=/172.16.162.238;bind_interface_str=;stats=true;name=VERIFY_SUSPECT;num_msgs=1;ergonomics=true;use_icmp=false;timeout=1500)
:BARRIER(id=0;max_close_time=60000;stats=true;name=BARRIER;ergonomics=true)
:pbcast.NAKACK2(use_mcast_xmit_req=false;use_mcast_xmit=false;max_msg_batch_size=500;xmit_from_random_member=false;stats=true;xmit_table_max_compaction_time=30000;log_not_found_msgs=true;ergonomics=true;discard_delivered_msgs=true;print_stability_history_on_failed_xmit=false;id=57;max_rebroadcast_timeout=2000;xmit_table_msgs_per_row=2000;xmit_table_num_rows=100;name=NAKACK2;log_discard_msgs=true;xmit_table_resize_factor=1.2;xmit_interval=1000)
:UNICAST(max_retransmit_time=60000;max_msg_batch_size=500;xmit_table_max_compaction_time=60000;stats=true;segment_capacity=1000;ergonomics=true;id=12;conn_expiry_timeout=60000;xmit_table_msgs_per_row=2000;xmit_table_num_rows=100;name=UNICAST;timeout=400,800,1600,3200;xmit_table_resize_factor=1.2;xmit_interval=2000)
:pbcast.STABLE(id=16;desired_avg_gossip=50000;max_bytes=4000000;stats=true;cap=0.1;name=STABLE;ergonomics=true;stability_delay=1000)
:pbcast.GMS(print_local_addr=true;stats=true;max_bundling_time=50;log_collect_msgs=true;resume_task_timeout=20000;log_view_warnings=true;num_prev_views=20;ergonomics=true;use_flush_if_present=true;print_physical_addrs=true;merge_timeout=5000;id=14;num_prev_mbrs=50;leave_timeout=1000;view_bundling=true;name=GMS;join_timeout=3000;handle_concurrent_startup=true;view_ack_collection_timeout=2000;max_join_attempts=0)
:UFC(id=45;max_block_time=5000;max_credits=2000000;stats=true;ignore_synchronous_response=true;min_credits=800000;name=UFC;min_threshold=0.4;ergonomics=true)
:MFC(id=44;max_block_time=5000;max_credits=2000000;stats=true;ignore_synchronous_response=true;min_credits=800000;name=MFC;min_threshold=0.4;ergonomics=true)
:FRAG2(id=5;frag_size=60000;stats=true;name=FRAG2;ergonomics=true)
:RSVP(id=55;stats=true;name=RSVP;resend_interval=2000;throw_exception_on_timeout=true;ergonomics=true;ack_on_delivery=true;timeout=10000)
:pbcast.STATE_TRANSFER(id=17;stats=true;name=STATE_TRANSFER;ergonomics=true)

?

?首次時緩存

50125 [http-bio-8080-exec-6] DEBUG org.mybatis.spring.SqlSessionUtils - Creating a new SqlSession 
50141 [http-bio-8080-exec-6] DEBUG org.mybatis.spring.SqlSessionUtils - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1f689a9] was not registered for synchronization because synchronization is not active 
50250 [http-bio-8080-exec-6] DEBUG o.a.i.cache.decorators.LoggingCache - Cache Hit Ratio [cn.zno.smse.dao.PersonMapper]: 0.0 
50282 [http-bio-8080-exec-6] DEBUG o.m.s.t.SpringManagedTransaction - JDBC Connection [29424556, URL=jdbc:oracle:thin:@//172.16.50.67:1521/orcl, UserName=E_CHANNEL, Oracle JDBC driver] will not be managed by Spring 
50282 [http-bio-8080-exec-6] DEBUG c.z.s.d.PersonMapper.countByExample - ooo Using Connection [29424556, URL=jdbc:oracle:thin:@//172.16.50.67:1521/orcl, UserName=E_CHANNEL, Oracle JDBC driver] 
50297 [http-bio-8080-exec-6] DEBUG c.z.s.d.PersonMapper.countByExample - ==>  Preparing: select count(*) from PERSON  
50454 [http-bio-8080-exec-6] DEBUG c.z.s.d.PersonMapper.countByExample - ==> Parameters:  
50547 [http-bio-8080-exec-6] DEBUG n.s.e.d.jgroups.JGroupsCachePeer - Created asynchronous message queue for 1000ms period 
50547 [http-bio-8080-exec-6] DEBUG org.mybatis.spring.SqlSessionUtils - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1f689a9] 
50547 [http-bio-8080-exec-6] DEBUG org.mybatis.spring.SqlSessionUtils - Creating a new SqlSession 
50547 [http-bio-8080-exec-6] DEBUG org.mybatis.spring.SqlSessionUtils - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@17c4e59] was not registered for synchronization because synchronization is not active 
50547 [http-bio-8080-exec-6] DEBUG o.a.i.cache.decorators.LoggingCache - Cache Hit Ratio [cn.zno.smse.dao.PersonMapper]: 0.0 
50579 [http-bio-8080-exec-6] DEBUG o.m.s.t.SpringManagedTransaction - JDBC Connection [33276711, URL=jdbc:oracle:thin:@//172.16.50.67:1521/orcl, UserName=E_CHANNEL, Oracle JDBC driver] will not be managed by Spring 
50579 [http-bio-8080-exec-6] DEBUG c.z.s.d.P.selectByExample - ooo Using Connection [33276711, URL=jdbc:oracle:thin:@//172.16.50.67:1521/orcl, UserName=E_CHANNEL, Oracle JDBC driver] 
50579 [http-bio-8080-exec-6] DEBUG c.z.s.d.P.selectByExample - ==>  Preparing: select * from ( select row_.*, rownum rownum_ from ( select ID, NAME, AGE, BIRTHDAY, TYPE, SEX from PERSON ) row_ ) where rownum_ > 0 and rownum_ <= 10  
50579 [http-bio-8080-exec-6] DEBUG c.z.s.d.P.selectByExample - ==> Parameters:  
50625 [http-bio-8080-exec-6] DEBUG org.mybatis.spring.SqlSessionUtils - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@17c4e59] 
51547 [EH_CACHE Async Replication Thread] DEBUG n.s.e.d.jgroups.JGroupsCachePeer - Sending 2 JGroupEventMessages from the asynchronous queue. 

?

命中緩存

59829 [http-bio-8080-exec-10] DEBUG org.mybatis.spring.SqlSessionUtils - Creating a new SqlSession 
59829 [http-bio-8080-exec-10] DEBUG org.mybatis.spring.SqlSessionUtils - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1f58af5] was not registered for synchronization because synchronization is not active 
59829 [http-bio-8080-exec-10] DEBUG o.a.i.cache.decorators.LoggingCache - Cache Hit Ratio [cn.zno.smse.dao.PersonMapper]: 0.3333333333333333 
59829 [http-bio-8080-exec-10] DEBUG org.mybatis.spring.SqlSessionUtils - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1f58af5] 
59829 [http-bio-8080-exec-10] DEBUG org.mybatis.spring.SqlSessionUtils - Creating a new SqlSession 
59829 [http-bio-8080-exec-10] DEBUG org.mybatis.spring.SqlSessionUtils - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1f12767] was not registered for synchronization because synchronization is not active 
59829 [http-bio-8080-exec-10] DEBUG o.a.i.cache.decorators.LoggingCache - Cache Hit Ratio [cn.zno.smse.dao.PersonMapper]: 0.5 
59829 [http-bio-8080-exec-10] DEBUG org.mybatis.spring.SqlSessionUtils - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1f12767] 

?

當執行更新操作時

361860 [http-bio-8080-exec-7] DEBUG n.s.e.d.j.JGroupsCacheReplicator - Remove all elements called on cn.zno.smse.dao.PersonMapper 

?

轉載于:https://www.cnblogs.com/zno2/p/4858397.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/286732.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/286732.shtml
英文地址,請注明出處:http://en.pswp.cn/news/286732.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

confluence5.8.10的使用

之前在windows上安裝了confluence5.8.10,結果有一天知什么緣故&#xff0c;數據庫數據損壞&#xff0c;知識庫徹底打不開了&#xff0c;所有的文檔都付之東流&#xff0c;真的不是一般心痛。因此考慮將其裝到linux機器上&#xff0c;因為tomcat和mysql實際上都為了linux而生的&…

Android之提示Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider

1 問題 接入SDK提示錯誤如下 java.lang.RuntimeException: Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.IllegalStateException: 2 解決辦法 在AndroidManifest.xml文件下面配置如下 在application目錄下面配置如下&#xff0c;…

RPA之PAD(Power Automate Desktop)組件開發

本文由網友藍創精英團隊投稿&#xff0c;歡迎轉載、分享原文作者&#xff1a;藍創精英團隊原文鏈接&#xff1a;https://blog.csdn.net/i2blue/article/details/125040323其實&#xff0c;PAD&#xff0c;現在官方文檔還沒有對外組件式或者插件式開發接口。但是&#xff0c;有一…

【地圖學】高斯-克呂格(Gauss-Kruger)投影原理、應用詳解(3°帶、6°帶)

一、高斯克呂格投影概述 德國數學家、物理學家、天文學家高斯于19 世紀20 年代擬定,后經德國大地測量學家克呂格于1912 年對投影公式加以補充,故稱為高斯-克呂格投影(Gauss-Kruger,簡稱GK),又名"等角橫切橢圓柱投影”。中央經線和赤道投影為相互垂直的直線,其它經線…

Linux安裝 微信開發者工具(deepin linux ubt)

一.環境:: deepin linux15.4.1 二.安裝過程: 2.1 安裝wine sudo apt-get install wine 2.2 安裝nwjs-sdk 2.2.1 下載linux版nwjs-sdk wget https://dl.nwjs.io/v0.25.4/nwjs-sdk-v0.25.4-linux-x64.tar.gz 2.2.2 解壓nwjs-sdk tar xvf nwjs-sdk-v0.25.4-linux-x64.tar.gz 2.2…

Python 3.6學習筆記(一)

開始之前 基礎示例 Python語法基礎&#xff0c;python語法比較簡單&#xff0c;采用縮緊方式。 # print absolute value of a integer a 100 if a > 0:print(a) else:print(-a) 可以看到&#xff0c;注釋以#開頭&#xff0c;python的變量不需要任何前綴&#xff0c;行結束不…

小程序的 HelloWord 01《 程序員變現指南之 微信QQ 小程序 真的零基礎開發寶典》

本系列教程是針對粉絲的變現教程&#xff0c;還不是粉絲的可以關注我并且到社區&#xff1a;https://bbs.csdn.net/topics/603436232 進行打卡&#xff0c;不是老粉的也可以獲取最終的技術變現學習&#xff0c;最終還有詳細的變現教程等你來。 前言 《 程序員變現指南之 微信…

octave中的一些基本操作

1.矩陣的表示&#xff1a;v [1 2 2] %表示1行3列的矩陣 v [1; 2; 2] %表示3行1列的矩陣 v [1 2; 2 3; 4 5] %3*2矩陣 size(v) % 求v的行與列 length(v) %求v的列 2.幾個基本矩陣的表示&#xff1a;1&#xff09;s ones(2, 4) %2*4全1矩陣 2&#xff09;m zeros(3, 4) %3…

Docker 日志最佳實踐

當運行在 docker 容器中的應用程序打印日志時&#xff0c;日志會輸出到標準輸出流 stdout 和標準錯誤流 stderr。容器日志驅動可以訪問這些流&#xff0c;并將日志發送到文件、本機運行的日志收集器或遠端的日志服務端點&#xff08;endpoint&#xff09;。本文將介紹選擇不同的…

Android之提示A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution

1 問題 編譯項目的時候提示錯誤如下 A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution 2 原因 有2次我寫room數據庫的時候都提示這個 ColumnInfo(name "isAddBookmark")var isAddBookmark falseColumnInfo(name "…

一個獲取a標簽傳值的函數

//獲取url查詢參數 var getUrlParams function () {var href"",params;return function (key,url) {if(url) {href url;params null;} else if(!url && !href) href window.location;//console.log(href);if(!params) {params {};var search href.sea…

【大地信】新時代GIS發展趨勢與未來展望

一、你必須知道的國內外知名學者 1. RogerTomlinson(羅杰湯姆林森)---GIS之父 Roger Tomlinson從1963年開始創建世界上第一個地理信息系統,即加拿大地理信息系統(CGIS)。因此,Tomlinson被譽為地理信息系統之父。 RogerTomlinson(1933.12---2014.2.9) 2. Michael Fran…

Python3.6學習筆記(二)

Python 的高級特性 切片 對于指定索引范圍取值的操作&#xff0c;Python提供了slice方法&#xff0c;類似于Excel中數據透視表的切片器。 >>> L [Michael, Sarah, Tracy, Bob, Jack’] #聲明一個List&#xff0c;取前三個值 >>> L[0:3] #表示從0開始&…

小程序獲取頭像試試水 02《 程序員變現指南之 微信QQ 小程序 真的零基礎開發寶典》

本系列教程是針對粉絲的變現教程&#xff0c;還不是粉絲的可以關注我并且到社區&#xff1a;https://bbs.csdn.net/topics/603436232 進行打卡&#xff0c;不是老粉的也可以獲取最終的技術變現學習&#xff0c;最終還有詳細的變現教程等你來。 前言 《 程序員變現指南之 微信…

VNX NETAPP NAS 備份恢復

做多少次快照的時間是自定義 的&#xff0c;例如可以每隔4小時做一次。 例如有A&#xff0c;B&#xff0c;C&#xff0c;D四個文件。 1&#xff09;第一次快照&#xff08;COW&#xff09;&#xff1a; 快照是瞬時的&#xff0c;拍照時候創建了一個快照空間&#xff0c;例如20%…

Git之cherry-pick命令

1 需求 有時需要把某遠程分支(比如dev分支)的某一次提交合并到另一遠程分支(比如master分支),這就需要用到git cherry-pick命令。 比如我們現在有0.1分支和0.2分支,我在0.1分支上提交了最后一次代碼,推上去了,現在需要合并這次提交到0.2 2 操作步驟 我們先到0.1分支…

【空間數據庫】時空數據庫,時態數據模型詳解

一、時態空間數據庫概述 現實世界的數據不僅與空間相關,而且與時間相關。在許多應用領域,如環境監測、搶險救災、交通管理、醫療救援等,相關數據隨著時間變化而變化,稱之為時態數據。很多空間數據庫應用都涉及時態數據,這些應用不僅需要存取空間數據庫的當前狀態,也需要存…

輸出日志實例改成用Spring的AOP來實現

1.采用Interception Around通知的形式實現 Interception Around通知會在Join Point的前后執行&#xff0c;實現Interception Around通知的類需要實現接口MethodInterceptor。其實現思路是&#xff1a; 1&#xff09;首先實現接口MethodInterceptor&#xff0c;在Invoke()方法里…

基于.NetCore開發博客項目 StarBlog - (9) 圖片批量導入

系列文章基于.NetCore開發博客項目 StarBlog - (1) 為什么需要自己寫一個博客&#xff1f;基于.NetCore開發博客項目 StarBlog - (2) 環境準備和創建項目基于.NetCore開發博客項目 StarBlog - (3) 模型設計基于.NetCore開發博客項目 StarBlog - (4) markdown博客批量導入基于.N…

zookeeper 入門講解實例 轉

轉 http://www.blogjava.net/BucketLi/archive/2010/12/21/341268.htmlzookeeper使用和原理探究&#xff08;一&#xff09;zookeeper介紹zookeeper是一個為分布式應用提供一致性服務的軟件&#xff0c;它是開源的Hadoop項目中的一個子項目&#xff0c;并且根據google發表的&l…