Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
ws-rst
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qlintonger xeno
ws-rst
Commits
175f2fc3
Commit
175f2fc3
authored
Feb 10, 2025
by
qlintonger xeno
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
redis-int+1
parent
0849b979
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 additions
and
5 deletions
+1
-5
src/client.rs
+1
-5
No files found.
src/client.rs
View file @
175f2fc3
...
@@ -53,10 +53,6 @@ async fn update_connected_redis() {
...
@@ -53,10 +53,6 @@ async fn update_connected_redis() {
let
connections
=
CONNECTIONS
.lock
()
.await
;
let
connections
=
CONNECTIONS
.lock
()
.await
;
let
from_ids
:
Vec
<
String
>
=
connections
.keys
()
.cloned
()
.collect
();
let
from_ids
:
Vec
<
String
>
=
connections
.keys
()
.cloned
()
.collect
();
let
mut
con
=
REDIS_POOL
.get_connection
()
.expect
(
"Failed to get Redis connection"
);
let
mut
con
=
REDIS_POOL
.get_connection
()
.expect
(
"Failed to get Redis connection"
);
// 先清空原有的列表
if
let
Err
(
e
)
=
con
.del
::
<
_
,
()
>
(
"connected"
)
{
println!
(
"Failed to delete old connected list in Redis: {}"
,
e
);
}
// 将每个 fromId 依次添加到列表中
// 将每个 fromId 依次添加到列表中
for
from_id
in
from_ids
{
for
from_id
in
from_ids
{
if
let
Err
(
e
)
=
con
.rpush
::
<
_
,
_
,
()
>
(
"connected"
,
from_id
)
{
if
let
Err
(
e
)
=
con
.rpush
::
<
_
,
_
,
()
>
(
"connected"
,
from_id
)
{
...
@@ -132,7 +128,7 @@ pub(crate) async fn handle_client(stream: tokio::net::TcpStream) -> Result<(), E
...
@@ -132,7 +128,7 @@ pub(crate) async fn handle_client(stream: tokio::net::TcpStream) -> Result<(), E
let
from_id
=
from_id
.clone
();
let
from_id
=
from_id
.clone
();
// 从 Redis 连接池获取连接
// 从 Redis 连接池获取连接
let
mut
con
=
REDIS_POOL
.get_connection
()
.expect
(
"Failed to get Redis connection"
);
let
con
=
REDIS_POOL
.get_connection
()
.expect
(
"Failed to get Redis connection"
);
// 检查 Redis 中是否已经存在该 fromId
// 检查 Redis 中是否已经存在该 fromId
close_existing_connection
(
&
from_id
)
.await
;
close_existing_connection
(
&
from_id
)
.await
;
...
...
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