File tree Expand file tree Collapse file tree 2 files changed +3
-0
lines changed
java/io/kimmking/cache/service Expand file tree Collapse file tree 2 files changed +3
-0
lines changed Original file line number Diff line number Diff line change @@ -14,11 +14,13 @@ public class UserServiceImpl implements UserService {
14
14
@ Autowired
15
15
UserMapper userMapper ;
16
16
17
+ // 开启spring cache
17
18
@ Cacheable (key ="#id" ,value ="userCache" )
18
19
public User find (int id ) {
19
20
return userMapper .find (id );
20
21
}
21
22
23
+ // 开启spring cache
22
24
@ Cacheable (key ="LIST" ,value ="userCache" )
23
25
public List <User > list (){
24
26
return userMapper .list ();
Original file line number Diff line number Diff line change 2
2
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
3
<mapper namespace =" io.kimmking.cache.mapper.UserMapper" >
4
4
5
+ <!-- 开启mybatis cache -->
5
6
<cache type =" org.mybatis.caches.ehcache.LoggingEhcache" >
6
7
<property name =" memoryStoreEvictionPolicy" value =" LRU" />
7
8
</cache >
You can’t perform that action at this time.
0 commit comments