Exemplo n.º 1
0
 private static async Task SaveTracking(int offSet, int limit, string lastKey)
 {
     var context  = GetContext();
     var tracking = new TrackingOffset {
         PartitionKey = $"ppham_{offSet}_{limit}", SortKey = $"ppham_{offSet}_{limit}", LastKey = lastKey
     };
     await context.SaveAsync(tracking, new DynamoDBOperationConfig()
     {
         OverrideTableName = TABLE
     });
 }
Exemplo n.º 2
0
        private async static Task <List <MyPoc> > GetWithOffsetAndLimit(int offSet, int limit)
        {
            if (offSet != 0)
            {
                TrackingOffset tracking = await GetTracking(offSet, limit);

                if (tracking == null)
                {
                    Console.WriteLine("Please start from Offset zero.");
                    return(null);
                }

                // Set tracking.Expiration = some config seconds

                //tracking.Expiration is valid ??

                var enrollments = await GetWithLastKey(tracking.LastKey);

                if (enrollments.Count >= LIMIT)
                {
                    await SaveTracking(offSet, limit, enrollments[LIMIT - 1].SortKey);

                    return(enrollments.Take(LIMIT).ToList());
                }
                else
                {
                    return(enrollments);
                }
            }
            else
            {
                var enrollments = await GetWithLimit(LIMIT);

                if (enrollments.Count >= LIMIT)
                {
                    await SaveTracking(offSet, limit, enrollments[LIMIT - 1].SortKey);

                    return(enrollments.Take(LIMIT).ToList());
                }
                else
                {
                    return(enrollments);
                }
            }
        }