Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
open-source
/
chejia-smart-service
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 52f25cfc
authored
Apr 13, 2021
by
111-PC\111
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]失败消息错误信息推送
1 parent
83ba0d0c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
0 deletions
src/main/java/com/glsx/smart/redis/RedisService.java
src/main/java/com/glsx/smart/redis/RedisService.java
0 → 100644
View file @
52f25cf
package
com
.
glsx
.
smart
.
redis
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.data.redis.core.*
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.concurrent.TimeUnit
;
/**
*
* redis 操作工具类
*/
@Component
public
class
RedisService
{
@Resource
(
name
=
"redisTemplate"
)
protected
RedisTemplate
<
Object
,
Object
>
redisTemplate
;
protected
Log
logger
=
LogFactory
.
getLog
(
getClass
());
public
void
set
(
String
key
,
Object
value
)
{
ValueOperations
valueOperations
=
redisTemplate
.
opsForValue
();
valueOperations
.
set
(
key
,
value
);
}
public
void
setOutTime
(
String
key
,
Object
value
,
long
timeout
,
TimeUnit
unit
)
{
ValueOperations
valueOperations
=
redisTemplate
.
opsForValue
();
valueOperations
.
set
(
key
,
value
,
timeout
,
unit
);
}
public
Object
get
(
String
key
)
{
return
redisTemplate
.
opsForValue
().
get
(
key
);
}
public
void
setList
(
String
key
,
List
<?>
value
)
{
ListOperations
listOperations
=
redisTemplate
.
opsForList
();
listOperations
.
leftPush
(
key
,
value
);
}
public
Object
getList
(
String
key
)
{
return
redisTemplate
.
opsForList
().
leftPop
(
key
);
}
public
void
setSet
(
String
key
,
Set
<?>
value
)
{
SetOperations
setOperations
=
redisTemplate
.
opsForSet
();
setOperations
.
add
(
key
,
value
);
}
public
Object
getSet
(
String
key
)
{
return
redisTemplate
.
opsForSet
().
members
(
key
);
}
public
void
setHash
(
String
key
,
Map
<
String
,
?>
value
)
{
HashOperations
hashOperations
=
redisTemplate
.
opsForHash
();
hashOperations
.
putAll
(
key
,
value
);
}
public
Object
getHash
(
String
key
)
{
return
redisTemplate
.
opsForHash
().
entries
(
key
);
}
public
void
delete
(
String
key
)
{
redisTemplate
.
delete
(
key
);
}
}
\ No newline at end of file
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
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 post a comment