Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录
切换导航
N
nestjs-redis
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
王智锐 (C)
nestjs-redis
Commits
db3ea4fc
提交
db3ea4fc
authored
9月 10, 2019
作者:
a
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(connection): disconnect sync
eliminate onModuleDestroy async flow since client.disconnect() is sync
上级
40c27c0c
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
20 行增加
和
30 行删除
+20
-30
redis-core.module.d.ts
dist/redis-core.module.d.ts
+1
-1
redis-core.module.js
dist/redis-core.module.js
+14
-24
redis-core.module.ts
lib/redis-core.module.ts
+5
-5
没有找到文件。
dist/redis-core.module.d.ts
浏览文件 @
db3ea4fc
...
@@ -7,5 +7,5 @@ export declare class RedisCoreModule implements OnModuleDestroy {
...
@@ -7,5 +7,5 @@ export declare class RedisCoreModule implements OnModuleDestroy {
constructor
(
options
:
RedisModuleOptions
|
RedisModuleOptions
[],
moduleRef
:
ModuleRef
);
constructor
(
options
:
RedisModuleOptions
|
RedisModuleOptions
[],
moduleRef
:
ModuleRef
);
static
register
(
options
:
RedisModuleOptions
|
RedisModuleOptions
[]):
DynamicModule
;
static
register
(
options
:
RedisModuleOptions
|
RedisModuleOptions
[]):
DynamicModule
;
static
forRootAsync
(
options
:
RedisModuleAsyncOptions
):
DynamicModule
;
static
forRootAsync
(
options
:
RedisModuleAsyncOptions
):
DynamicModule
;
onModuleDestroy
():
Promise
<
void
>
;
onModuleDestroy
():
void
;
}
}
dist/redis-core.module.js
浏览文件 @
db3ea4fc
...
@@ -11,14 +11,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
...
@@ -11,14 +11,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
var
__param
=
(
this
&&
this
.
__param
)
||
function
(
paramIndex
,
decorator
)
{
var
__param
=
(
this
&&
this
.
__param
)
||
function
(
paramIndex
,
decorator
)
{
return
function
(
target
,
key
)
{
decorator
(
target
,
key
,
paramIndex
);
}
return
function
(
target
,
key
)
{
decorator
(
target
,
key
,
paramIndex
);
}
};
};
var
__awaiter
=
(
this
&&
this
.
__awaiter
)
||
function
(
thisArg
,
_arguments
,
P
,
generator
)
{
return
new
(
P
||
(
P
=
Promise
))(
function
(
resolve
,
reject
)
{
function
fulfilled
(
value
)
{
try
{
step
(
generator
.
next
(
value
));
}
catch
(
e
)
{
reject
(
e
);
}
}
function
rejected
(
value
)
{
try
{
step
(
generator
[
"throw"
](
value
));
}
catch
(
e
)
{
reject
(
e
);
}
}
function
step
(
result
)
{
result
.
done
?
resolve
(
result
.
value
)
:
new
P
(
function
(
resolve
)
{
resolve
(
result
.
value
);
}).
then
(
fulfilled
,
rejected
);
}
step
((
generator
=
generator
.
apply
(
thisArg
,
_arguments
||
[])).
next
());
});
};
Object
.
defineProperty
(
exports
,
"__esModule"
,
{
value
:
true
});
Object
.
defineProperty
(
exports
,
"__esModule"
,
{
value
:
true
});
var
RedisCoreModule_1
;
var
RedisCoreModule_1
;
const
common_1
=
require
(
"@nestjs/common"
);
const
common_1
=
require
(
"@nestjs/common"
);
...
@@ -50,23 +42,21 @@ let RedisCoreModule = RedisCoreModule_1 = class RedisCoreModule {
...
@@ -50,23 +42,21 @@ let RedisCoreModule = RedisCoreModule_1 = class RedisCoreModule {
};
};
}
}
onModuleDestroy
()
{
onModuleDestroy
()
{
return
__awaiter
(
this
,
void
0
,
void
0
,
function
*
()
{
const
closeConnection
=
({
clients
,
defaultKey
})
=>
options
=>
{
const
closeConnection
=
({
clients
,
defaultKey
})
=>
(
options
)
=>
__awaiter
(
this
,
void
0
,
void
0
,
function
*
()
{
const
name
=
options
.
name
||
defaultKey
;
const
name
=
options
.
name
||
defaultKey
;
const
client
=
clients
.
get
(
name
);
const
client
=
clients
.
get
(
name
);
if
(
client
&&
!
options
.
keepAlive
)
{
if
(
client
&&
!
options
.
keepAlive
)
{
client
.
disconnect
();
yield
client
.
disconnect
();
}
});
const
redisClient
=
this
.
moduleRef
.
get
(
redis_constants_1
.
REDIS_CLIENT
);
const
closeClientConnection
=
closeConnection
(
redisClient
);
if
(
Array
.
isArray
(
this
.
options
))
{
yield
Promise
.
all
(
this
.
options
.
map
(
closeClientConnection
));
}
else
{
yield
closeClientConnection
(
this
.
options
);
}
}
});
};
const
redisClient
=
this
.
moduleRef
.
get
(
redis_constants_1
.
REDIS_CLIENT
);
const
closeClientConnection
=
closeConnection
(
redisClient
);
if
(
Array
.
isArray
(
this
.
options
))
{
this
.
options
.
forEach
(
closeClientConnection
);
}
else
{
closeClientConnection
(
this
.
options
);
}
}
}
};
};
RedisCoreModule
=
RedisCoreModule_1
=
__decorate
([
RedisCoreModule
=
RedisCoreModule_1
=
__decorate
([
...
...
lib/redis-core.module.ts
浏览文件 @
db3ea4fc
...
@@ -50,13 +50,13 @@ export class RedisCoreModule implements OnModuleDestroy {
...
@@ -50,13 +50,13 @@ export class RedisCoreModule implements OnModuleDestroy {
};
};
}
}
async
onModuleDestroy
()
{
onModuleDestroy
()
{
const
closeConnection
=
({
clients
,
defaultKey
})
=>
async
options
=>
{
const
closeConnection
=
({
clients
,
defaultKey
})
=>
options
=>
{
const
name
=
options
.
name
||
defaultKey
;
const
name
=
options
.
name
||
defaultKey
;
const
client
=
clients
.
get
(
name
);
const
client
=
clients
.
get
(
name
);
if
(
client
&&
!
options
.
keepAlive
)
{
if
(
client
&&
!
options
.
keepAlive
)
{
await
client
.
disconnect
();
client
.
disconnect
();
}
}
};
};
...
@@ -64,9 +64,9 @@ export class RedisCoreModule implements OnModuleDestroy {
...
@@ -64,9 +64,9 @@ export class RedisCoreModule implements OnModuleDestroy {
const
closeClientConnection
=
closeConnection
(
redisClient
);
const
closeClientConnection
=
closeConnection
(
redisClient
);
if
(
Array
.
isArray
(
this
.
options
))
{
if
(
Array
.
isArray
(
this
.
options
))
{
await
Promise
.
all
(
this
.
options
.
map
(
closeClientConnection
)
);
this
.
options
.
forEach
(
closeClientConnection
);
}
else
{
}
else
{
await
closeClientConnection
(
this
.
options
);
closeClientConnection
(
this
.
options
);
}
}
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论