Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
streamingUserPortrait
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵威
streamingUserPortrait
Commits
5250cae6
Commit
5250cae6
authored
Feb 07, 2021
by
赵威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
write json
parent
41bdc245
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
+9
-4
Redis.scala
src/main/scala/com.gmei.up/utils/Redis.scala
+9
-4
No files found.
src/main/scala/com.gmei.up/utils/Redis.scala
View file @
5250cae6
...
@@ -4,6 +4,10 @@ import scala.concurrent.Future
...
@@ -4,6 +4,10 @@ import scala.concurrent.Future
import
scala.collection.JavaConverters._
import
scala.collection.JavaConverters._
import
com.alibaba.fastjson.JSON
import
com.alibaba.fastjson.JSON
import
com.redis.
{
RedisClient
,
RedisClientPool
}
import
com.redis.
{
RedisClient
,
RedisClientPool
}
import
org.json4s._
import
org.json4s.jackson.Serialization
import
org.json4s.jackson.Serialization.
{
read
,
write
}
import
org.json4s.jackson.JsonMethods._
object
Redis
{
object
Redis
{
// TODO read from config file
// TODO read from config file
...
@@ -65,6 +69,8 @@ object Redis {
...
@@ -65,6 +69,8 @@ object Redis {
contentEitherFuture
:
Either
[
Throwable
,
Future
[
IndexedSeq
[
Content
]]],
contentEitherFuture
:
Either
[
Throwable
,
Future
[
IndexedSeq
[
Content
]]],
deviceId
:
String
deviceId
:
String
)
:
Unit
=
{
)
:
Unit
=
{
implicit
val
formats
=
Serialization
.
formats
(
NoTypeHints
)
val
key
=
s
"streaming:candidate:service_diary:device_id:${deviceId}"
val
key
=
s
"streaming:candidate:service_diary:device_id:${deviceId}"
contentEitherFuture
match
{
contentEitherFuture
match
{
case
Left
(
e
)
=>
e
.
printStackTrace
()
case
Left
(
e
)
=>
e
.
printStackTrace
()
...
@@ -72,12 +78,11 @@ object Redis {
...
@@ -72,12 +78,11 @@ object Redis {
pRc4
.
withClient
{
client
=>
pRc4
.
withClient
{
client
=>
contentFuture
.
foreach
{
seq
=>
contentFuture
.
foreach
{
seq
=>
val
idPairs
=
seq
.
map
(
c
=>
(
c
.
id
,
c
.
serviceId
.
getOrElse
(
"-1"
)))
val
idPairs
=
seq
.
map
(
c
=>
(
c
.
id
,
c
.
serviceId
.
getOrElse
(
"-1"
)))
println
(
idPairs
)
val
a
=
write
(
idPairs
)
println
(
a
)
if
(
idPairs
.
size
>
0
)
{
if
(
idPairs
.
size
>
0
)
{
client
.
del
(
key
)
client
.
del
(
key
)
idPairs
.
foreach
{
pair
=>
client
.
set
(
key
,
a
)
client
.
rpush
(
key
,
pair
)
}
}
}
}
}
}
}
...
...
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