ttl can not be added when using dynamodb-onetable

Viewed 133

I'm using dynamodb-onetable and trying to add ttl to the Model in a schema as described here: https://github.com/sensedeep/dynamodb-onetable

this is what my model looks like

SocketSession: {
            pk: { type: String, value: "${_type}_${socketSessionId}" },
            sk: { type: String, value: "${_type}_" },
            socketSessionId: { type: String },
            userId: { type: String },
            ttl: { 
                ttl: true, 
                type: Number, default: () => {
                return Math.floor(Date.now() / 1000 + 10)
            } },
            gs1pk: { type: String, value: "${_type}_" },
            gs1sk: { type: String, value: "${_type}_${socketSessionId}" },
        }

The date is inserted into the TTL field correctly but nothing happens after 10 seconds. the entry stays there.

What am I missing?

2 Answers

From the DynamoDB documentation:

"Depending on the size and activity level of a table, the actual delete operation of an expired item can vary. Because TTL is meant to be a background process, the nature of the capacity used to expire and delete items via TTL is variable (but free of charge). TTL typically deletes expired items within 48 hours of expiration."

Related