Deleting the first few entries in the dynamo-db list is due to field values ​​or number of items

I have a dataset in dynamoDB that looks like this:

{
    "userID" : 2323423,    // Primary Key
    "lt" :  [
            {
                  "timestamp"   : epoch1,
                  "coordinates" : "coordinate1"
            },
            {
                  "timestamp"   : epoch2,
                  "coordinates" : "coordinate2"
            },
            ...
        ]
}

"lt" is a location tracking list that is designed to store coordinate values ​​for a user ID at different times.

Q1 Requirement:

  • Save location tracking data for a maximum of 1 day for each user, while automatic deletion occurs only when a new entry of LT coordinate data is received.
  • What this means is, at the same time, there may be outdated LT data, each of which has a duration of 24 hours. However, as soon as new LT coordinate data appears, delete the obsolete records to delete records older than 24 hours.

, dynamoDB.

UpdateExpression: "REMOVE lt [0]" -

UpdateExpression: "REMOVE lt [0] lt [1]" - 0 1

, 24 . , , , , . - ?

Q2 :

  • 100 "lt".
  • LT , LT .

N LT , "n" , 100 + "n" . 100, .

, , N "lt" , , , "n" , , " , " lt ". , "lt" - Count, .

, ?

+4
1

. , HH: MM - . SET lt.#hhmm = :coord ExpressionAttributeNames={#hhmm:"16:05"} ExpressionAttributeValues={:coord:"0,0"}. , 24 * 60 = 1440 lt. 19 , 30 43 , .

, 43 WCU 1 WCU . . 30- , 48 24- . , UpdateItem 1 WCU 60 WCU . - <user_id>_HH:<00 or 30>.

0

Source: https://habr.com/ru/post/1652582/


All Articles