In actual use, it is found that the reading operations on the table_info and users tables at the bottom of the Pharos are too frequent. Therefore, the secondary cache is added for these tables to improve performance.
0. First modify the hibernate. properties file,
Add
Hibernate. cache. provider_class = net. SF. hibernate. cache. ehcacheprovider
Hibernate. cache. use_query_cache = true
1. Modify endbran/src/Java/ehcache. xml and add the following content:
<Cache name = "com. vtradex. endbrain. model. tableinfo"
Maxelementsinmemory = "1000"
Eternal = "true"
Timetoidleseconds = "86400"
Timetoliveseconds = "86400"
Overflowtodisk = "true"
/>
<Cache name = "com. vtradex. endbrain. model. tableinfo. excludedcolumns"
Maxelementsinmemory = "1000"
Eternal = "true"
Timetoidleseconds = "86400"
Timetoliveseconds = "86400"
Overflowtodisk = "true"
/>
<Cache name = "com. vtradex. Bedrock. model. Security. User"
Maxelementsinmemory = "1000"
Eternal = "true"
Timetoidleseconds = "86400"
Timetoliveseconds = "86400"
Overflowtodisk = "true"
/>
<Cache name = "com. vtradex. Bedrock. model. Security. User. Roles"
Maxelementsinmemory = "1000"
Eternal = "true"
Timetoidleseconds = "86400"
Timetoliveseconds = "86400"
Overflowtodisk = "true"
/>
<Cache name = "com. vtradex. Bedrock. model. Security. User. Groups"
Maxelementsinmemory = "1000"
Eternal = "true"
Timetoidleseconds = "86400"
Timetoliveseconds = "86400"
Overflowtodisk = "true"
/>
<Cache name = "com. vtradex. Bedrock. model. Security. User. Authorizations"
Maxelementsinmemory = "1000"
Eternal = "true"
Timetoidleseconds = "86400"
Timetoliveseconds = "86400"
Overflowtodisk = "true"
/>
2. Modify COM/vtradex/endbrain/Dao/hibernate/tableinfo. HBM. xml
2.1 Add to the class definition
<Cache Usage = "nonstrict-read-write"/>
2.2 In <set name = "excludedcolumns" table = "table_column">
Add below
<Cache Usage = "read-write"/>
3. Modify com. vtradex. endbrain. Dao. hibernate. hibernatetableinfodao.
In the gettableinfobyidentity and gettableinfosbypage methods
Add
Setcacheable (true)
Setcacheregion ("com. vtradex. endbrain. model. tableinfo ")
4. Modify COM/vradex/bedrock/Dao/security/hibernate/user. HBM. xml
4.1 Add to the class definition
<Cache Usage = "nonstrict-read-write"/>
4.2 In <set name = "Roles" table = "user_role" lazy = "true" cascade = "Save-Update">
<Set name = "groups" table = "group_user" lazy = "true" inverse = "true">
<Set name = "authorizations" table = "user_authorization" lazy = "true" inverse = "true" cascade = "all-delete-Orphan">
Add
<Cache Usage = "read-write"/>
5. Modify com. vtradex. Bedrock. Dao. Security. hibernate. hibernateuserdao.
In the getuserbyloginname method
Add
Setcacheable (true)
Setcacheregion ("com. vtradex. Bedrock. model. Security. User ")