Question

Let's say I'm trying to log some program's output to DynamoDB table, but I need to keep let's say only the last 5000 rows. What's the best way to achieve that? I mean it's sounds like a bit extreme to check every single time when I need to put something in there and check if that would overfill the limit, retrieve the first row and delete it.

Was it helpful?

Solution

How would you do it in RAM? You would use a circular buffer. Do the same thing on DynamoDB. Each time you write to the table, increment the primary key and modulo it 5000.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top