Skip to content
This repository has been archived by the owner on Aug 17, 2023. It is now read-only.

Commit

Permalink
fix evalauto command
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Oct 12, 2017
1 parent f66051c commit 8a62fd6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion lib/commands.js
Expand Up @@ -309,12 +309,19 @@ exports.initCommands = function (proto) {

if (connection.evalshaP[script]) {
args[0] = yield connection.evalshaP[script]
return yield connection.sendCommand('evalsha', args)
try {
return yield connection.sendCommand('evalsha', args)
} catch (err) {
if (err.name !== 'NOSCRIPT') throw err
// try to load script
args[0] = script
}
}

let res = yield connection.sendCommand('eval', args)
// connection maybe change with MOVED response
connection = this._redisState.getConnection(slot)
if (connection instanceof Error) throw connection
connection.evalshaP[script] = thunk.promise(connection.sendCommand('script', ['load', script]))
return res
})
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "thunk-redis",
"version": "2.1.5",
"version": "2.1.6",
"description": "The fastest thunk/promise-based redis client, support all redis features.",
"main": "lib/index.js",
"authors": [
Expand Down

0 comments on commit 8a62fd6

Please sign in to comment.