Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
head_group
xyqb-user2
Commits
0972d902
Commit
0972d902
authored
Jun 04, 2018
by
技术部-任文超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加共享内存,解决跨JVM线程无法同步问题
parent
fab89b05
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
UserCenterServiceImpl.java
...ntgroup/xyqb/service/user/impl/UserCenterServiceImpl.java
+6
-1
No files found.
src/main/java/cn/quantgroup/xyqb/service/user/impl/UserCenterServiceImpl.java
View file @
0972d902
...
@@ -5,6 +5,8 @@ import cn.quantgroup.xyqb.repository.IUserAttachedRepository;
...
@@ -5,6 +5,8 @@ import cn.quantgroup.xyqb.repository.IUserAttachedRepository;
import
cn.quantgroup.xyqb.service.user.UserCenterService
;
import
cn.quantgroup.xyqb.service.user.UserCenterService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.sql.Timestamp
;
import
java.sql.Timestamp
;
...
@@ -21,11 +23,13 @@ public class UserCenterServiceImpl implements UserCenterService {
...
@@ -21,11 +23,13 @@ public class UserCenterServiceImpl implements UserCenterService {
private
IUserAttachedRepository
userAttachedRepository
;
private
IUserAttachedRepository
userAttachedRepository
;
@Override
@Override
@Cacheable
(
value
=
"userAttachedCache"
,
key
=
"'xyqbUserAttached' + #userId"
,
unless
=
"#result == null"
,
cacheManager
=
"cacheManager"
)
public
UserAttached
searchUserAttachedByUserId
(
long
userId
)
{
public
UserAttached
searchUserAttachedByUserId
(
long
userId
)
{
return
userAttachedRepository
.
findByUserId
(
userId
);
return
userAttachedRepository
.
findByUserId
(
userId
);
}
}
@Override
@Override
@CacheEvict
(
value
=
"userAttachedCache"
,
key
=
"'xyqbUserAttached' + #userId"
,
cacheManager
=
"cacheManager"
)
public
UserAttached
saveUserAvatar
(
long
userId
,
String
avatar
)
{
public
UserAttached
saveUserAvatar
(
long
userId
,
String
avatar
)
{
UserAttached
userAttached
=
userAttachedRepository
.
findByUserId
(
userId
);
UserAttached
userAttached
=
userAttachedRepository
.
findByUserId
(
userId
);
if
(
Objects
.
isNull
(
userAttached
)){
if
(
Objects
.
isNull
(
userAttached
)){
...
@@ -40,6 +44,7 @@ public class UserCenterServiceImpl implements UserCenterService {
...
@@ -40,6 +44,7 @@ public class UserCenterServiceImpl implements UserCenterService {
}
}
@Override
@Override
@CacheEvict
(
value
=
"userAttachedCache"
,
key
=
"'xyqbUserAttached' + #userId"
,
cacheManager
=
"cacheManager"
)
public
UserAttached
saveUserNick
(
long
userId
,
String
nick
)
{
public
UserAttached
saveUserNick
(
long
userId
,
String
nick
)
{
UserAttached
userAttached
=
userAttachedRepository
.
findByUserId
(
userId
);
UserAttached
userAttached
=
userAttachedRepository
.
findByUserId
(
userId
);
if
(
Objects
.
isNull
(
userAttached
)){
if
(
Objects
.
isNull
(
userAttached
)){
...
@@ -62,7 +67,7 @@ public class UserCenterServiceImpl implements UserCenterService {
...
@@ -62,7 +67,7 @@ public class UserCenterServiceImpl implements UserCenterService {
* @return
* @return
*/
*/
private
synchronized
UserAttached
createUserAttached
(
Long
userId
,
String
avatar
,
String
nick
)
{
private
synchronized
UserAttached
createUserAttached
(
Long
userId
,
String
avatar
,
String
nick
)
{
UserAttached
userAttached
=
userAttachedRepository
.
fin
dByUserId
(
userId
);
UserAttached
userAttached
=
this
.
searchUserAttache
dByUserId
(
userId
);
// 更新实例
// 更新实例
userAttached
=
Optional
.
ofNullable
(
userAttached
).
orElse
(
new
UserAttached
());
userAttached
=
Optional
.
ofNullable
(
userAttached
).
orElse
(
new
UserAttached
());
Timestamp
now
=
new
Timestamp
(
System
.
currentTimeMillis
());
Timestamp
now
=
new
Timestamp
(
System
.
currentTimeMillis
());
...
...
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