Skip to content

Commit

Permalink
Converting strings to numbers for comparison in lua script (#3847)
Browse files Browse the repository at this point in the history
_Lua will automatically convert string and number types to the correct format to perform calculations. (...) A notable exception: comparison operators (== ~= < > <= >=) do not coerce their arguments._

Fixes: #3767
  • Loading branch information
moozzyk committed Jan 30, 2017
1 parent ca0872d commit e847b78
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Microsoft.AspNet.SignalR.Redis/RedisConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ public async Task RestoreLatestValueForKey(int database, string key)
}

var redisResult = await _connection.GetDatabase(database).ScriptEvaluateAsync(
@"local newvalue = redis.call('GET', KEYS[1])
if not newvalue or newvalue < ARGV[1] then
@"local newvalue = tonumber(redis.call('GET', KEYS[1]))
if not newvalue or tonumber(newvalue) < tonumber(ARGV[1]) then
return redis.call('SET', KEYS[1], ARGV[1])
else
return nil
Expand Down

0 comments on commit e847b78

Please sign in to comment.