How to solve the performance problem through level 2 cache (ehcache)

Source: Internet
Author: User

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 ")

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.