Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录
切换导航
N
nestjs-redis
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
王智锐 (C)
nestjs-redis
Commits
73203d71
提交
73203d71
authored
12月 06, 2018
作者:
zzy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add async function
上级
2d8a4b6a
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
78 行增加
和
9 行删除
+78
-9
README.md
README.md
+17
-0
redis-client.provider.d.ts
dist/redis-client.provider.d.ts
+6
-1
redis-client.provider.js
dist/redis-client.provider.js
+5
-0
redis.interface.d.ts
dist/redis.interface.d.ts
+5
-0
redis.module.d.ts
dist/redis.module.d.ts
+2
-1
redis.module.js
dist/redis.module.js
+11
-0
redis-client.provider.ts
lib/redis-client.provider.ts
+9
-2
redis.interface.ts
lib/redis.interface.ts
+8
-2
redis.module.ts
lib/redis.module.ts
+15
-3
没有找到文件。
README.md
浏览文件 @
73203d71
...
@@ -30,6 +30,23 @@ import { RedisModule} from 'nestjs-redis'
...
@@ -30,6 +30,23 @@ import { RedisModule} from 'nestjs-redis'
})
})
export
class
AppModule
{}
export
class
AppModule
{}
```
```
With Async
```
typescript
import
{
Module
}
from
'@nestjs/common'
;
import
{
RedisModule
}
from
'nestjs-redis'
@
Module
({
imports
:
[
RedisModuleforRootAsync
({
useFactory
:
(
configService
:
ConfigService
)
=>
configService
.
get
(
'redis'
),
// or use async method
//useFactory: async (configService: ConfigService) => configService.get('redis'),
inject
:[
ConfigService
]
}),
],
})
export
class
AppModule
{}
```
Options
Options
```
typescript
```
typescript
interface
RedisOptions
{
interface
RedisOptions
{
...
...
dist/redis-client.provider.d.ts
浏览文件 @
73203d71
import
*
as
Redis
from
"ioredis"
;
import
*
as
Redis
from
"ioredis"
;
import
{
RedisModuleOptions
}
from
"./redis.interface"
;
import
{
RedisModuleOptions
,
RedisModuleAsyncOptions
}
from
"./redis.interface"
;
export
declare
const
createClient
:
()
=>
{
export
declare
const
createClient
:
()
=>
{
provide
:
symbol
;
provide
:
symbol
;
useFactory
:
(
options
:
RedisModuleOptions
)
=>
Redis
.
Redis
;
useFactory
:
(
options
:
RedisModuleOptions
)
=>
Redis
.
Redis
;
inject
:
symbol
[];
inject
:
symbol
[];
};
};
export
declare
const
createAsyncClientOptions
:
(
options
:
RedisModuleAsyncOptions
)
=>
{
provide
:
symbol
;
useFactory
:
(...
args
:
any
[])
=>
RedisModuleOptions
|
Promise
<
RedisModuleOptions
>
;
inject
:
any
[];
};
dist/redis-client.provider.js
浏览文件 @
73203d71
...
@@ -9,3 +9,8 @@ exports.createClient = () => ({
...
@@ -9,3 +9,8 @@ exports.createClient = () => ({
},
},
inject
:
[
redis_constants_1
.
REDIS_MODULE_OPTIONS
]
inject
:
[
redis_constants_1
.
REDIS_MODULE_OPTIONS
]
});
});
exports
.
createAsyncClientOptions
=
(
options
)
=>
({
provide
:
redis_constants_1
.
REDIS_MODULE_OPTIONS
,
useFactory
:
options
.
useFactory
,
inject
:
options
.
inject
});
dist/redis.interface.d.ts
浏览文件 @
73203d71
import
{
ModuleMetadata
}
from
'@nestjs/common/interfaces'
;
import
{
RedisOptions
}
from
'ioredis'
;
import
{
RedisOptions
}
from
'ioredis'
;
export
interface
RedisModuleOptions
extends
RedisOptions
{
export
interface
RedisModuleOptions
extends
RedisOptions
{
}
}
export
interface
RedisModuleAsyncOptions
extends
Pick
<
ModuleMetadata
,
'imports'
>
{
useFactory
?:
(...
args
:
any
[])
=>
RedisModuleOptions
|
Promise
<
RedisModuleOptions
>
;
inject
?:
any
[];
}
dist/redis.module.d.ts
浏览文件 @
73203d71
import
{
DynamicModule
}
from
'@nestjs/common'
;
import
{
DynamicModule
}
from
'@nestjs/common'
;
import
{
RedisModuleOptions
}
from
'./redis.interface'
;
import
{
RedisModuleOptions
,
RedisModuleAsyncOptions
}
from
'./redis.interface'
;
export
declare
class
RedisModule
{
export
declare
class
RedisModule
{
static
register
(
options
:
RedisModuleOptions
):
DynamicModule
;
static
register
(
options
:
RedisModuleOptions
):
DynamicModule
;
static
forRootAsync
(
options
:
RedisModuleAsyncOptions
):
DynamicModule
;
}
}
dist/redis.module.js
浏览文件 @
73203d71
...
@@ -22,6 +22,17 @@ let RedisModule = RedisModule_1 = class RedisModule {
...
@@ -22,6 +22,17 @@ let RedisModule = RedisModule_1 = class RedisModule {
exports
:
[
redis_service_1
.
RedisService
]
exports
:
[
redis_service_1
.
RedisService
]
};
};
}
}
static
forRootAsync
(
options
)
{
return
{
module
:
RedisModule_1
,
imports
:
options
.
imports
,
providers
:
[
redis_client_provider_1
.
createClient
(),
redis_client_provider_1
.
createAsyncClientOptions
(
options
),
],
exports
:
[
redis_service_1
.
RedisService
]
};
}
};
};
RedisModule
=
RedisModule_1
=
__decorate
([
RedisModule
=
RedisModule_1
=
__decorate
([
common_1
.
Global
(),
common_1
.
Global
(),
...
...
lib/redis-client.provider.ts
浏览文件 @
73203d71
import
*
as
Redis
from
"ioredis"
import
*
as
Redis
from
"ioredis"
import
{
REDIS_CLIENT
,
REDIS_MODULE_OPTIONS
}
from
'./redis.constants'
;
import
{
REDIS_CLIENT
,
REDIS_MODULE_OPTIONS
}
from
'./redis.constants'
;
import
{
RedisModuleOptions
}
from
"./redis.interface"
;
import
{
RedisModuleOptions
,
RedisModuleAsyncOptions
}
from
"./redis.interface"
;
export
const
createClient
=
()
=>
({
export
const
createClient
=
()
=>
({
provide
:
REDIS_CLIENT
,
provide
:
REDIS_CLIENT
,
...
@@ -8,4 +8,11 @@ export const createClient = () => ({
...
@@ -8,4 +8,11 @@ export const createClient = () => ({
return
new
Redis
(
options
)
return
new
Redis
(
options
)
},
},
inject
:[
REDIS_MODULE_OPTIONS
]
inject
:[
REDIS_MODULE_OPTIONS
]
})
})
\ No newline at end of file
export
const
createAsyncClientOptions
=
(
options
:
RedisModuleAsyncOptions
)
=>
({
provide
:
REDIS_MODULE_OPTIONS
,
useFactory
:
options
.
useFactory
,
inject
:
options
.
inject
})
\ No newline at end of file
lib/redis.interface.ts
浏览文件 @
73203d71
import
{
RedisOptions
}
from
'ioredis'
import
{
ModuleMetadata
}
from
'@nestjs/common/interfaces'
;
import
{
RedisOptions
}
from
'ioredis'
;
export
interface
RedisModuleOptions
extends
RedisOptions
{}
export
interface
RedisModuleOptions
extends
RedisOptions
{}
\ No newline at end of file
export
interface
RedisModuleAsyncOptions
extends
Pick
<
ModuleMetadata
,
'imports'
>
{
useFactory
?:
(...
args
:
any
[])
=>
RedisModuleOptions
|
Promise
<
RedisModuleOptions
>
,
inject
?:
any
[];
}
\ No newline at end of file
lib/redis.module.ts
浏览文件 @
73203d71
import
{
DynamicModule
,
Module
,
Global
}
from
'@nestjs/common'
;
import
{
DynamicModule
,
Module
,
Global
}
from
'@nestjs/common'
;
import
{
RedisModuleOptions
}
from
'./redis.interface'
;
import
{
RedisModuleOptions
,
RedisModuleAsyncOptions
}
from
'./redis.interface'
;
import
{
REDIS_MODULE_OPTIONS
}
from
'./redis.constants'
;
import
{
REDIS_MODULE_OPTIONS
}
from
'./redis.constants'
;
import
{
RedisService
}
from
'./redis.service'
;
import
{
RedisService
}
from
'./redis.service'
;
import
{
createClient
}
from
'./redis-client.provider'
;
import
{
createClient
,
createAsyncClientOptions
}
from
'./redis-client.provider'
;
@
Global
()
@
Global
()
@
Module
({
@
Module
({
...
@@ -15,7 +15,19 @@ export class RedisModule {
...
@@ -15,7 +15,19 @@ export class RedisModule {
module
:
RedisModule
,
module
:
RedisModule
,
providers
:
[
providers
:
[
createClient
(),
createClient
(),
{
provide
:
REDIS_MODULE_OPTIONS
,
useValue
:
options
}
{
provide
:
REDIS_MODULE_OPTIONS
,
useValue
:
options
}
],
exports
:
[
RedisService
]
}
}
static
forRootAsync
(
options
:
RedisModuleAsyncOptions
)
:
DynamicModule
{
return
{
module
:
RedisModule
,
imports
:
options
.
imports
,
providers
:
[
createClient
(),
createAsyncClientOptions
(
options
),
],
],
exports
:
[
RedisService
]
exports
:
[
RedisService
]
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论