Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
open-source
/
glsx-smart-message-channel
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 09604223
authored
Apr 22, 2021
by
111-PC\111
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]pulsar消费服务
1 parent
44f0d754
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
79 additions
and
0 deletions
src/main/java/cn/com/glsx/consumer/redis/RedisService.java
src/main/java/cn/com/glsx/consumer/redis/RedisService.java
0 → 100644
View file @
0960422
package
cn
.
com
.
glsx
.
consumer
.
redis
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.data.redis.core.HashOperations
;
import
org.springframework.data.redis.core.ListOperations
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.SetOperations
;
import
org.springframework.data.redis.core.ValueOperations
;
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
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
void
setOutTime
(
String
key
,
Object
value
,
long
timeout
,
TimeUnit
unit
)
{
ValueOperations
valueOperations
=
redisTemplate
.
opsForValue
();
valueOperations
.
set
(
key
,
value
,
timeout
,
unit
);
}
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