Menu

Expand
Rate this page:

Sync Objects Time-To-Live (TTL)

By default, data you store in Sync is permanent: Twilio will not delete your data for you, and you can rely on it always being there. If you do explicitly delete your data, we will delete it immediately per our commitment to GDPR principles. But otherwise, Twilio will retain your Sync objects indefinitely and you can expect your data to be there.

For purposes of garbage collection, or even time-based user experiences, we also provide a Time-to-live (TTL) feature. A TTL value, assignable to any Sync object (including items within Maps and Lists) specifies the approximate time before the object is automatically garbage-collected by Twilio, disappearing from SDKs and from the REST API.

This TTL setting are fixed, and do not advance automatically with data updates. If you want to move a timer forward automatically, you must explicitly provide a new TTL value with the next data update.

Example Code

The following code pushes a List Item. This item will disappear approximately a week later.

const weekInSeconds = 7 * 24 * 3600;
syncClient.list('notification_history').then(function(list) {
  list.push({
    title: 'New message arrived'
  }, {
    ttl: weekInSeconds
  });
});

Precision & Accuracy

In favor of high scale, Sync's TTL implementation sacrifices accurate firing times. While you can rely on these timers to drive timed application behavior, you should expect that long timers fire inaccurately: up to minutes away from the moment of expiry. They will often be more accurate than this in practice.

Rate this page:

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.

Loading Code Sample...
        
        
        

        Thank you for your feedback!

        Please select the reason(s) for your feedback. The additional information you provide helps us improve our documentation:

        Sending your feedback...
        🎉 Thank you for your feedback!
        Something went wrong. Please try again.

        Thanks for your feedback!

        thanks-feedback-gif