Esempio n. 1
0
        private bool SetIncCount()
        {
            RedisValue token  = Environment.MachineName;
            RedisKey   key    = "locktake";
            var        db     = redisHelper.GetDatabase();
            bool       result = db.LockTake(key, token, TimeSpan.FromSeconds(100));

            if (result)
            {
                try
                {
                    int count = redisHelper.StringGet <int>("get_count_notInc");
                    count++;
                    Console.WriteLine($"count:{count}");
                    redisHelper.StringSet("get_count_notInc", count);
                }
                catch
                {
                }
                finally
                {
                    db.LockRelease(key, token);
                }
            }
            return(result);
        }