Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录
切换导航
N
nestjs-redis
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
王智锐 (C)
nestjs-redis
Commits
6faeb435
提交
6faeb435
authored
7月 23, 2019
作者:
zzy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#17 add url for redisOptions
上级
53eda8f2
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
42 行增加
和
12 行删除
+42
-12
README.md
README.md
+6
-5
redis-client.provider.js
dist/redis-client.provider.js
+18
-3
redis.interface.d.ts
dist/redis.interface.d.ts
+1
-0
redis-client.provider.ts
lib/redis-client.provider.ts
+15
-3
redis.interface.ts
lib/redis.interface.ts
+2
-1
没有找到文件。
README.md
浏览文件 @
6faeb435
...
...
@@ -56,17 +56,17 @@ export default {
password
:
process
.
env
.
REDIS_PASSWORD
,
keyPrefix
:
process
.
env
.
REDIS_PRIFIX
,
}
Or
export
default
{
url
:
'redis://:authpassword@127.0.0.1:6380/4'
,
}
```
With multi client
```
typescript
export
default
[
{
name
:
'test1'
,
host
:
process
.
env
.
REDIS_HOST
,
port
:
parseInt
(
process
.
env
.
REDIS_PORT
),
db
:
parseInt
(
process
.
env
.
REDIS_DB
),
password
:
process
.
env
.
REDIS_PASSWORD
,
keyPrefix
:
process
.
env
.
REDIS_PRIFIX
,
url
:
'redis://:authpassword@127.0.0.1:6380/4'
,
},
{
name
:
'test2'
,
...
...
@@ -101,6 +101,7 @@ interface RedisOptions {
* client name. default is a uuid, unique.
*/
name
?:
string
;
url
?:
string
;
port
?:
number
;
host
?:
string
;
/**
...
...
dist/redis-client.provider.js
浏览文件 @
6faeb435
...
...
@@ -17,19 +17,34 @@ exports.createClient = () => ({
if
(
clients
.
has
(
o
.
name
))
{
throw
new
RedisClientError
(
`client
${
o
.
name
}
is exists`
);
}
if
(
o
.
url
)
{
clients
.
set
(
o
.
name
,
new
Redis
(
o
.
url
));
}
else
{
clients
.
set
(
o
.
name
,
new
Redis
(
o
));
}
}
else
{
if
(
clients
.
has
(
defaultKey
))
{
throw
new
RedisClientError
(
'default client is exists'
);
}
if
(
o
.
url
)
{
clients
.
set
(
defaultKey
,
new
Redis
(
o
.
url
));
}
else
{
clients
.
set
(
defaultKey
,
new
Redis
(
o
));
}
}
}
}
else
{
if
(
options
.
url
)
{
clients
.
set
(
defaultKey
,
new
Redis
(
options
.
url
));
}
else
{
clients
.
set
(
defaultKey
,
new
Redis
(
options
));
}
}
return
{
defaultKey
,
clients
,
...
...
dist/redis.interface.d.ts
浏览文件 @
6faeb435
...
...
@@ -2,6 +2,7 @@ import { ModuleMetadata } from '@nestjs/common/interfaces';
import
{
RedisOptions
}
from
'ioredis'
;
export
interface
RedisModuleOptions
extends
RedisOptions
{
name
?:
string
;
url
?:
string
;
}
export
interface
RedisModuleAsyncOptions
extends
Pick
<
ModuleMetadata
,
'imports'
>
{
useFactory
?:
(...
args
:
any
[])
=>
RedisModuleOptions
|
RedisModuleOptions
[]
|
Promise
<
RedisModuleOptions
>
|
Promise
<
RedisModuleOptions
[]
>
;
...
...
lib/redis-client.provider.ts
浏览文件 @
6faeb435
...
...
@@ -22,17 +22,29 @@ export const createClient = () => ({
if
(
clients
.
has
(
o
.
name
))
{
throw
new
RedisClientError
(
`client
${
o
.
name
}
is exists`
);
}
if
(
o
.
url
)
{
clients
.
set
(
o
.
name
,
new
Redis
(
o
.
url
));
}
else
{
clients
.
set
(
o
.
name
,
new
Redis
(
o
));
}
}
else
{
if
(
clients
.
has
(
defaultKey
))
{
throw
new
RedisClientError
(
'default client is exists'
);
}
if
(
o
.
url
)
{
clients
.
set
(
defaultKey
,
new
Redis
(
o
.
url
));
}
else
{
clients
.
set
(
defaultKey
,
new
Redis
(
o
));
}
}
}
}
else
{
if
(
options
.
url
)
{
clients
.
set
(
defaultKey
,
new
Redis
(
options
.
url
));
}
else
{
clients
.
set
(
defaultKey
,
new
Redis
(
options
));
}
}
return
{
defaultKey
,
clients
,
...
...
lib/redis.interface.ts
浏览文件 @
6faeb435
...
...
@@ -2,7 +2,8 @@ import { ModuleMetadata } from '@nestjs/common/interfaces';
import
{
RedisOptions
}
from
'ioredis'
;
export
interface
RedisModuleOptions
extends
RedisOptions
{
name
?:
string
;
name
?:
string
url
?:
string
}
export
interface
RedisModuleAsyncOptions
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论