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 our Twilio Community forums or browsing the Twilio tag on Stack Overflow.

        
        
        

        Thank you for your feedback!

        We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

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

        Thanks for your feedback!

        Refer us and get $10 in 3 simple steps!

        Step 1

        Get link

        Get a free personal referral link here

        Step 2

        Give $10

        Your user signs up and upgrade using link

        Step 3

        Get $10

        1,250 free SMSes
        OR 1,000 free voice mins
        OR 12,000 chats
        OR more