Get a complete flytable table with disk caching and delta sync
Source:R/flytable-cache.R
flytable_cached_table.RdFetches a complete flytable table using disk caching with
intelligent delta synchronization. On first call, downloads the full table.
On subsequent calls within expiry seconds, returns cached data.
After expiry, performs delta sync fetching only rows modified since last
sync based on the _mtime column.
Usage
flytable_cached_table(
table,
expiry = 0,
refresh = FALSE,
collapse_lists = TRUE,
base = NULL,
limit = 100000L
)Arguments
- table
Table name (e.g., "info", "optic", "testfruit")
- expiry
Seconds before checking for updates (default 0, i.e. always check for updates on every call). Set to a positive number of seconds to reduce network chatter by trusting the cache within that window, or
Infto never check i.e. to use what is available on disk. Note that anexpiry = 0check is still cheap because it only downloads rows modified since the last sync (a delta sync).- refresh
Logical. If
TRUE, forces a complete re-download ignoring any cached data. DefaultFALSE.- collapse_lists
Logical. If
TRUE(default), collapses multi-select columns into comma-separated strings. Passed toflytable_query.- base
Optional base name if table name is ambiguous (exists in multiple bases).
- limit
An optional limit on the total number of rows returned, which only applies if you do not specify a limit directly in the
sqlquery. By default seatable limits SQL queries to 100 rows. We increase the limit to 100000 rows by default. Seepaginatefor how this interacts with the server's per-call row cap.
Value
A data.frame containing all rows from the table. Has an
mtime attribute recording the server timestamp at last sync.
Details
The function uses the same disk cache infrastructure as
flywire_leaves. The cache location can be controlled via the
fafbseg.cachedir option.
Delta synchronization works by:
Checking if cached data exists and is within the expiry window
If expired, querying rows where
_mtime > cached_mtimeUpdating modified rows, appending new rows
Detecting and removing deleted rows via row count comparison
Error handling:
Connection failures during sync: returns cached data with warning
Schema changes (columns differ): forces full refresh
Corrupted cache: clears and re-fetches
Examples
if (FALSE) { # \dontrun{
# First call - full fetch
info <- flytable_cached_table("info")
# Subsequent call - delta syncs any changes since the last fetch (default
# expiry = 0 always checks)
info2 <- flytable_cached_table("info")
# Trust the cache for 5 minutes before checking again
info3 <- flytable_cached_table("info", expiry = 300)
# Force complete re-download
info4 <- flytable_cached_table("info", refresh = TRUE)
# Check when data was last synced
attr(info, "mtime")
} # }