Created
August 13, 2014 20:42
-
-
Save stimms/846a8107e451c2afbcf7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Fact] | |
public void EvalTest() | |
{ | |
var redisConnection = GetRedisConnection(); | |
redisConnection.StringSet("foo", 77); | |
redisConnection.StringSet("foo.count", 1); | |
var result = redisConnection.ScriptEvaluate(@"local currentval = redis.call('get', ARGV[1]) | |
local currentcount = redis.call('get', ARGV[1] .. '.count') | |
redis.call('incr', ARGV[1] .. '.count') | |
currentval = (currentval * (currentcount/(currentcount + 1))) + (ARGV[2]/(currentcount+1)) | |
redis.call('set', ARGV[1], currentval) | |
return currentval", null, new RedisValue[] { "foo", 11 }, CommandFlags.None); | |
((int)result).Should().Be.EqualTo(44); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment