using (var datalock = redisdb.AcquireLock("test", TimeSpan.FromSeconds(2)) { //阻塞锁 ////todo } var isok=redis.Add<string>("lockdata2","locakdata2",TimeSpan.FromSeconds(2)); // 非阻塞锁 if(isok) { /// todo }
using (var client=new redisClient("192.168.******"),6379)
{
client.ExecLuaAsString(@"redis.call('set','name','jaosn')");
client.ExecLuaAsString(@"return redis.call('set','name')");
}
/// lua 脚本 key 和argv 都是参数化的意思 。点赞 点踩的应用场景
redis SREM zset 的方法
var lua = @"local count = redis.call('SISMEMBER',KEYS[1],ARGV[1]) if(tonumber(count)>=0) then redis.call('SREM',KEYS[1],ARGV[1]) else end redis.call('SADD',KEYS[2],ARGV[1]) "; Console.WriteLine(client.ExecLuaAsString(lua, keys: new string[] { "abs:Content:1:Up", "abs:Content:1:Down" }, args: new string[] { "2" }));