Background Sync Pro
The background sync system is the engine behind AUTO LINKS. It processes items in configurable batches using the WordPress cron system.
Technical flow
- Cron fires at the configured frequency.
- A transient lock (
ails_auto_sync_lock, 5-minute TTL) prevents overlapping runs. - The plugin fetches one batch of posts starting from the stored offset.
- For each post, it prepares link data (post ID, title, focus keyword, URL, default attributes).
- If the post does not already exist in the log table, a new entry is inserted.
- The offset is incremented for the next batch.
- When no more posts remain, the offset resets and a sync timestamp is recorded.
Cache management
After each batch, the plugin updates cached badge counts and sync totals arithmetically instead of clearing the entire cache. This reduces database load on large sites.
Monitoring
The last 5 synced items are stored in ails_last_synced_items for dashboard display. The admin menu badge shows the count of pending items.