예제 #1
0
        private void AddBatchableOperation(BatchableOperation requestedOperation)
        {
            // Note: it can take 0.5 seconds for each single Delete or Create operation,
            // so try to batch them up so it doesn't take as long
            //
            // One at a time, it took 493.84 seconds to process 439 records.
            // In batch, it took 101.93 seconds to process the same 439 records.
            // That's 493.84 / 101.93 = 4.8x speedup

            _batchableOperations.Add(requestedOperation);
            if (_batchableOperations.Count >= 50)
            {
                FlushBatchableOperations();
            }
        }
예제 #2
0
        /// <summary>
        /// Schedules an object to be deleted the next time a batch of operations is sent.
        /// Remember to call FlushBatchableOperations at the end.
        /// A batch will also be sent automatically when the batch queue is full.
        /// </summary>
        /// <param name="className">The class to delete from</param>
        /// <param name="objectId">The object ID to delete</param>
        internal void RequestDeleteObject(string className, string objectId)
        {
            var requestedOperation = new BatchableOperation(RestSharp.Method.DELETE, $"classes/{className}/{objectId}", "{}");

            AddBatchableOperation(requestedOperation);
        }
예제 #3
0
        /// <summary>
        /// Schedules an object to be added the next time a batch of operations is sent.
        /// Remember to call FlushBatchableOperations at the end.
        /// A batch will also be sent automatically when the batch queue is full.
        /// </summary>
        /// <param name="className">The class to add to</param>
        /// <param name="objectId">The JSON of the object to create</param>
        internal void RequestCreateObject(string className, string json)
        {
            var requestedOperation = new BatchableOperation(RestSharp.Method.POST, $"classes/{className}", json);

            AddBatchableOperation(requestedOperation);
        }