Skip to contentSkip to navigationSkip to topbar
Rate this page:
On 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(link takes you to an external page). 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 is fixed and does 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

example-code page anchor

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


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


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: