public object Get(PostgreSqlUpdatesRequest request)
        {
            // limit queries to be between 1 and 500 iterations
            var worldCount = Math.Max(1, Math.Min(500, (int)request.queries));

            // concurrently create a list of random world ids to update
            var ids = new List <int>(worldCount);

            Parallel.For(0, worldCount, i =>
            {
                lock (ids)
                {
                    ids.Add(SafeRandom.Instance.Next(0, 10000) + 1);
                }
            });

            // purge cache client
            Cache.FlushAll();

            // update the worlds
            using (var db = dbFactory.OpenDbConnection())
            {
                return(db.UpdateWorlds(ids));
            }
        }
Exemplo n.º 2
0
 public object Get(PostgreSqlUpdatesRequest request)
 {
     using (var db = dbFactory.OpenDbConnection())
     {
         var worldCount = Math.Max(1, Math.Min(500, (int)request.queries)); // limit queries to be between 1 and 500 iterations
         return(new HttpResult(db.UpdateRandomWorlds(worldCount, new Random()), ContentType.Json));
     }
 }