TableData

TableData

  • Automatically load table data from a CACHE or SHEET
  • In all cases, if the cache has expired, the data is read from the sheet.
Cache Seconds Description
0 Data is not cached and always read directly from SHEET
<= 21600 Data read from SHEETS cache if it has not expired
> 21600 Data read from Google Sheets Script Settings

Constructor

new TableData()

Source:

Methods

(static) cacheGetArray(cache, namedRange) → {Array.<Array.<any>>}

Description:
  • Reads cache for range, and re-assembles blocks into return array of data.

Source:
Parameters:
Name Type Description
cache Object
namedRange String
Returns:
Type
Array.<Array.<any>>

(static) cachePutArray(cache, namedRange, cacheSeconds, arrData)

Description:
  • Takes array data to be cached, breaks up into chunks if necessary, puts each chunk into cache and updates status.

Source:
Parameters:
Name Type Description
cache Object
namedRange String
cacheSeconds Number
arrData Array.<Array.<any>>

(static) cacheStatusName(namedRange) → {String}

Source:
Parameters:
Name Type Description
namedRange String
Returns:
Type
String

(static) fixJSONdates(arrData)

Description:
  • Dates retrieved from a JSON structure need to be converted to JS date.

Source:
Parameters:
Name Type Description
arrData Array.<Array.<any>>

(static) forceLongCacheExpiryCheck()

Description:
  • In the interest of testing, force the expiry check. It does not mean items in cache will be removed - just forces a check.

Source:

(static) getValueCached(namedRange, seconds) → {any}

Description:
  • Reads a single cell.

Source:
Parameters:
Name Type Default Description
namedRange String
seconds Number 60
Returns:
Type
any

(static) getValuesCached(namedRange, seconds) → {Array.<Array.<any>>}

Description:
  • Reads a RANGE of values.

Source:
Parameters:
Name Type Description
namedRange String
seconds Number
Returns:
Type
Array.<Array.<any>>

(static) isRangeLoading(namedRange) → {Boolean}

Description:
  • Checks if this range is loading elsewhere (i.e. from another call to custom function)

Source:
Parameters:
Name Type Description
namedRange String
Returns:
Type
Boolean

(static) isTimeToRunLongCacheExpiry() → {Boolean}

Description:
  • Is it time to run the long term cache expiry check?

Source:
Returns:
Type
Boolean

(static) loadTableData(namedRange, cacheSeconds) → {Array.<Array.<any>>}

Description:
  • Retrieve table data from SHEET or CACHE.

Source:
Parameters:
Name Type Default Description
namedRange String

Location of table data. Either a) SHEET Name, b) Named Range, c) A1 sheet notation.

cacheSeconds Number 0

0s Reads directly from sheet. > 21600s Sets in SCRIPT settings, else CacheService

Returns:
Type
Array.<Array.<any>>

(static) loadValuesFromRangeOrSheet(namedRange) → {Array.<Array.<any>>}

Description:
  • Read sheet data into double array.

Source:
Parameters:
Name Type Description
namedRange String

named range, A1 notation or sheet name

Returns:
  • table data.
Type
Array.<Array.<any>>

(static) lockLoadAndCache(cache, namedRange, cacheSeconds) → {Array.<Array.<any>>}

Description:
  • Read range of value from sheet and cache.

Source:
Parameters:
Name Type Description
cache Object

cache object can vary depending where the data is stored.

namedRange String
cacheSeconds Number
Returns:
  • data from range
Type
Array.<Array.<any>>

(static) setLongCacheExpiry()

Description:
  • The long term expiry check is done every 21,000 seconds. Set the clock now!

Source:

(static) setValueCached(namedRange, singleData, seconds)

Description:
  • For updating a sheet VALUE that may be later read from cache.

Source:
Parameters:
Name Type Default Description
namedRange String
singleData any
seconds Number 60

(static) setValuesCached(namedRange, arrData, seconds)

Description:
  • For updating a sheet array that may be later read from cache.

Source:
Parameters:
Name Type Default Description
namedRange String
arrData Array.<Array.<any>>
seconds Number 60

(static) verifyCachedData(arrData) → {Boolean}

Description:
  • Check if data from cache is in error.

Source:
Parameters:
Name Type Description
arrData Array.<Array.<any>>
Returns:
Type
Boolean

(static) waitForRangeToLoad(cache, namedRange, cacheSeconds) → {Array.<Array.<any>>}

Description:
  • Retrieve data from cache after it has loaded elsewhere.

Source:
Parameters:
Name Type Description
cache Object
namedRange String
cacheSeconds Number

How long to cache results.

Returns:
Type
Array.<Array.<any>>