Skip to content

Instantly share code, notes, and snippets.

@stimms
Created August 13, 2014 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stimms/846a8107e451c2afbcf7 to your computer and use it in GitHub Desktop.
Save stimms/846a8107e451c2afbcf7 to your computer and use it in GitHub Desktop.
[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