Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
52cc82c6
Commit
52cc82c6
authored
Dec 11, 2019
by
宋毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tj
parent
6205f98c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
22 deletions
+49
-22
igirl-channel/app/base/utils/redisClient.js
+49
-22
No files found.
igirl-channel/app/base/utils/redisClient.js
View file @
52cc82c6
...
...
@@ -7,30 +7,57 @@ bluebird.promisifyAll(redis);
class
RedisClient
{
constructor
()
{
const
redisConfig
=
settings
.
redis
();
this
.
client
=
redis
.
createClient
({
host
:
redisConfig
.
host
,
port
:
redisConfig
.
port
,
password
:
redisConfig
.
password
,
db
:
redisConfig
.
db
,
retry_strategy
:
function
(
options
)
{
// if (options.error && options.error.code === 'ECONNREFUSED') {
// // End reconnecting on a specific error and flush all commands with
// // a individual error
// return new Error('The server refused the connection');
// }
if
(
options
.
total_retry_time
>
1000
*
60
*
60
)
{
// End reconnecting after a specific timeout and flush all commands
// with a individual error
return
new
Error
(
'Retry time exhausted'
);
this
.
client
=
null
;
if
(
!
redisConfig
.
password
)
{
this
.
client
=
redis
.
createClient
({
host
:
redisConfig
.
host
,
port
:
redisConfig
.
port
,
db
:
redisConfig
.
db
,
retry_strategy
:
function
(
options
)
{
// if (options.error && options.error.code === 'ECONNREFUSED') {
// // End reconnecting on a specific error and flush all commands with
// // a individual error
// return new Error('The server refused the connection');
// }
if
(
options
.
total_retry_time
>
1000
*
60
*
60
)
{
// End reconnecting after a specific timeout and flush all commands
// with a individual error
return
new
Error
(
'Retry time exhausted'
);
}
if
(
options
.
attempt
>
10
)
{
// End reconnecting with built in error
return
10000
;
}
// reconnect after
return
Math
.
min
(
options
.
attempt
*
100
,
3000
);
}
if
(
options
.
attempt
>
10
)
{
// End reconnecting with built in error
return
10000
;
});
}
else
{
this
.
client
=
redis
.
createClient
({
host
:
redisConfig
.
host
,
port
:
redisConfig
.
port
,
password
:
redisConfig
.
password
,
db
:
redisConfig
.
db
,
retry_strategy
:
function
(
options
)
{
// if (options.error && options.error.code === 'ECONNREFUSED') {
// // End reconnecting on a specific error and flush all commands with
// // a individual error
// return new Error('The server refused the connection');
// }
if
(
options
.
total_retry_time
>
1000
*
60
*
60
)
{
// End reconnecting after a specific timeout and flush all commands
// with a individual error
return
new
Error
(
'Retry time exhausted'
);
}
if
(
options
.
attempt
>
10
)
{
// End reconnecting with built in error
return
10000
;
}
// reconnect after
return
Math
.
min
(
options
.
attempt
*
100
,
3000
);
}
// reconnect after
return
Math
.
min
(
options
.
attempt
*
100
,
3000
);
}
});
});
}
// return client.multi().get('foo').execAsync().then(function(res) {
// console.log(res); // => 'bar'
...
...
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