File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
module-domain/src/main/java/com/mile/moim/service/popular Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,6 @@ private Set<MoimCuriousWriter> getMoimCuriousWriter(final List<PostAndCuriousCou
47
47
48
48
@ CachePut (value = "moimPopularInfo" , key = "#moim.id" )
49
49
public MoimPopularInfo setMostPopularInfoOfMoim (final Moim moim ) {
50
- distributedLock .getLock ("MOIM_POPULAR_LOCK" );
51
50
52
51
List <PostAndCuriousCountInLastWeek > mostCuriousPostsInLastWeek = curiousRetriever .findMostCuriousPostsInLastWeek (moim );
53
52
@@ -59,7 +58,7 @@ public MoimPopularInfo setMostPopularInfoOfMoim(final Moim moim) {
59
58
60
59
moimPopularInfoRepository .saveAndFlush (moimPopularInfo );
61
60
62
- distributedLock .afterLock ("MOIM_POPULAR_LOCK" );
61
+ distributedLock .afterLock ("MOIM_POPULAR_LOCK" + moim . getId () );
63
62
64
63
return moimPopularInfo ;
65
64
}
Original file line number Diff line number Diff line change 1
1
package com .mile .moim .service .popular ;
2
2
3
3
import com .mile .common .CacheService ;
4
+ import com .mile .common .lock .DistributedLock ;
4
5
import com .mile .moim .domain .Moim ;
5
6
import com .mile .moim .domain .popular .MoimPopularInfo ;
6
7
import com .mile .moim .repository .MoimPopularInfoRepository ;
@@ -17,13 +18,17 @@ public class MoimPopularInfoService {
17
18
private final MoimPopularInfoRepository moimPopularInfoRepository ;
18
19
private final MoimPopularInfoRegister moimPopularInfoRegister ;
19
20
private final SendMessageModule sendMessageModule ;
21
+ private final DistributedLock distributedLock ;
20
22
private final CacheService cacheService ;
21
23
22
24
23
25
@ Cacheable (value = "moimPopularInfo" , key = "#moim.id" )
24
26
public MoimPopularInfo getMoimPopularInfo (final Moim moim ) {
25
27
return moimPopularInfoRepository .findByMoimId (moim .getId ()).orElseGet (
26
- () -> moimPopularInfoRegister .setMostPopularInfoOfMoim (moim )
28
+ () -> {
29
+ distributedLock .getLock ("MOIM_POPULAR_LOCK" + moim .getId ());
30
+ return moimPopularInfoRegister .setMostPopularInfoOfMoim (moim );
31
+ }
27
32
);
28
33
}
29
34
You can’t perform that action at this time.
0 commit comments