Exemple #1
0
        public static string GetSeqNoByRedisLock()
        {
            string connectionStr  = "server = localhost; user id = oec2003; password = 123456; database = seqno_test";
            string getSeqNosql    = "select num from seqno where code='order'";
            string updateSeqNoSql = "update seqno set num=num+1 where code='order'";

            var seqNo = string.Empty;

            using (_redisClient.Lock("test", 5000))
            {
                seqNo = MySQLHelper.ExecuteScalar(connectionStr, System.Data.CommandType.Text, getSeqNosql).ToString();

                MySQLHelper.ExecuteNonQuery(connectionStr, System.Data.CommandType.Text, updateSeqNoSql);
            }
            return(seqNo);
        }