GetPrecalculatedData (open)

Get precalculated data, run in standalone job

Syntax

LOADLIB "mod::system/lib/cache.whlib";

ASYNC FUNCTION GetPrecalculatedData(RECORD keydata, STRING func, RECORD options)

Parameters

RECORD keydata

Key data (not bound to calling library!)

STRING func

Function to calculate values (format 'library#functionname'). Will be invoked with the specified keydata Its return value must be a record, and can have the following fields:

  • value: value (should be a record)
  • softttl: TTL in ms for soft expiry (mutually exclusive with softexpiry)
  • softeventmasks: Event masks for soft expiry
  • softexpires: Date when item soft expires (mutually exclusive with softttl)
  • ttl: TTL in ms for expiry (mutually exclusive with softexpiry)
  • eventmasks: Event masks for expiry
  • expires: Date when item expires (mutually exclusive with softttl)
  • crashretry: Cache period for crashes (retried after this period)
  • liverefreshtimeout: Max time to wait for new value after normal expiry (before falling back to cached value)

Soft expiry and normal expiry both trigger background refresh. A soft expired value is returned immediately, a normal expired value is scheduled for refresh, and the new value is returned - except when that refresh crashes or runs past the liverefreshtimeout. In that cache, the old cached value is returned.

Initial crashes are cached for 60 seconds.

RECORD options

Options

forcerefresh

If TRUE, for recalculation even if not soft-expired yet.

waitforrefresh

If TRUE, wait for recalculation of soft-expired data too (waiting until recalculation is finished, ignoring liverefreshtimeout)

Return value

Precalculated data