Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wecloud_im_server
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hewei
wecloud_im_server
Commits
4a21fdbb
Commit
4a21fdbb
authored
Jan 21, 2022
by
hweeeeeei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化:根据id查询会话调用频率较高,增加redis缓存,有修改数据库时能同步清空redis该会话数据
parent
55d3156d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
core/src/main/java/com/wecloud/im/service/ImConversationService.java
+8
-0
core/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
+17
-0
No files found.
core/src/main/java/com/wecloud/im/service/ImConversationService.java
View file @
4a21fdbb
...
...
@@ -104,6 +104,14 @@ public interface ImConversationService extends BaseService<ImConversation> {
ImConversationQueryVo
getImConversationById
(
Long
id
);
/**
* 删除redis中该会话的缓存
*
* @param id
*/
void
deleteCacheImConversationById
(
Long
id
);
/**
* 获取分页对象
*
* @param imConversationPageParam
...
...
core/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
View file @
4a21fdbb
...
...
@@ -45,6 +45,9 @@ import io.geekidea.springbootplus.framework.shiro.util.JwtUtil;
import
io.geekidea.springbootplus.framework.shiro.util.SnowflakeUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -62,6 +65,7 @@ import java.util.Map;
*/
@Slf4j
@Service
@CacheConfig
(
cacheNames
=
"convstn"
)
public
class
ImConversationServiceImpl
extends
BaseServiceImpl
<
ImConversationMapper
,
ImConversation
>
implements
ImConversationService
{
@Autowired
...
...
@@ -621,6 +625,9 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
imConversationById
.
setName
(
imConversationNameUpdate
.
getName
());
boolean
b
=
imConversationService
.
updateById
(
imConversationById
);
// 删除redis中该会话的缓存
deleteCacheImConversationById
(
imConversationNameUpdate
.
getConversationId
());
if
(
b
)
{
// 下发群名称变动事件
...
...
@@ -703,6 +710,10 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
imConversationById
.
setAttributes
(
attributes
);
boolean
b
=
imConversationService
.
updateById
(
imConversationById
);
// 删除redis中该会话的缓存
deleteCacheImConversationById
(
imConversationAttrUpdate
.
getConversationId
());
if
(
b
)
{
...
...
@@ -785,11 +796,17 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
}
@Override
@Cacheable
(
key
=
"#p0"
)
public
ImConversationQueryVo
getImConversationById
(
Long
id
)
{
return
imConversationMapper
.
getImConversationById
(
id
);
}
@Override
@CacheEvict
(
key
=
"#p0"
)
public
void
deleteCacheImConversationById
(
Long
id
)
{
}
@Override
public
Paging
<
ImConversationQueryVo
>
getImConversationPageList
(
ImConversationPageParam
imConversationPageParam
)
throws
Exception
{
Page
<
ImConversationQueryVo
>
page
=
new
PageInfo
<>(
imConversationPageParam
,
OrderItem
.
desc
(
getLambdaColumn
(
ImConversation:
:
getCreateTime
)));
IPage
<
ImConversationQueryVo
>
iPage
=
imConversationMapper
.
getImConversationPageList
(
page
,
imConversationPageParam
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment