The Jitterbit Cloud Cache is a gratifying assignable space to persist data between Operation executions. They are used like Global variables with some exceptions.

  • Values are set and returned via specific Cloud Caching functions (WriteCache() and ReadCache())
  • Make up to 50 calls per minute. This is an increase from a previous limit of 25 calls per minute.
  • The caching functions are only usable within a running Operation (we cannot use them in a test mode)
  • The persistence can be local to a project or an entire Jitterbit environment.
  • There is a configurable expiration (maximum: 30 days but specified in seconds, or 2,592,000 seconds)
  • The default expiration is 30 minutes (1800 seconds).

I find Cloud Cached variables useful for

  • persisting polling values (a scheduled query to get endpoint records that were modified after a cloud cached date). You will want to update the cloud variable only upon success.
  • keys used in REST authentication or session ID reuse (if Cloud Cached value expired, generate a new key or ID within the Operation).
  • counter values if tracking an error count between Operation executions–to limit possible alert storms.

Note the calls per minute limit if your recurrences are high.

You can read the Jitterbit materials on cloud caching in their best practice materials or their Cloud Cache Functions page.

I’ve created wrapper scripts for calling the Write/ReadCache() functions. This way, I can trap any errors, send unique parameters as needed, log any desired details, and even confirm or retry if network trouble.
After listing their parameters, you can find my Scripts further below. Note, the scripts use the Event Script discussed in the Capturing Events and Errors post.

Script parameters for Utilities/Set Cloud Cache

Returns the value that was set.
1. Name (required)
2. Value (defaults to a value of the Agent’s local time)
3. Expiration in seconds (this script defaults to 2,592,000 seconds)
4. Scope (defaults to “project”)
5. Maximum retries to confirm (using ReadCache(), defaults to 5 retries)

Script parameters for Utilities/Get Cloud Cache

Returns the named value if available
1. Name (required)
2. Expiration (for expiration reset, defaults to existing expiration)
3. Scope (for scope reset, defaults to existing scope)
4. Maximum retries (in case, defaults to 5)

Set Cloud Cache

LOG_level=$LOG.level; $LOG.level="Critical"; // so not as chatty
//   Note, arguments cannot be skipped; use "" for unused arguments
//RunScript("<TAG>Scripts/Handlers/Event</TAG>",7,"Set Cloud Cache: args",
//  Quote(_1)+', '+Quote(_2)+', '+Quote(_3)+', '+Quote(_4));
_name   = IfEmpty(_1,RaiseError("Write cache with no variable name provided"));
defaultValue=Now();
_value  = IfEmpty(_2,RunScript("<TAG>Scripts/Handlers/Event</TAG>",5,
  "Set Cloud Cache: Default value [Now() timestamp] used for Cloud Cache variable"
  +Quote(_name),defaultValue); defaultValue);
defaultExpire=Long(-1);
_expire = IfEmpty(_3,
  RunScript("<TAG>Scripts/Handlers/Event</TAG>",6,
    "Set Cloud Cache: Default expiration (30d from now) used for Cloud Cache variable ("+_name+")",
      Date(Long(_value)+defaultExpire)); 
  defaultExpire
);
_scope  = IfEmpty(_4,RunScript("<TAG>Scripts/Handlers/Event</TAG>",7,
  "Set Cloud Cache: Using Cloud Cache scope (project) for "
  +_name,Quote('project')); "project");
_maxRetries = IfEmpty(_5, 5);

WriteCache(_name, _value, _expire, _scope);

retry=0; While( (Eval(value = ReadCache(_name,_expire,_scope), "ERROR") == "ERROR") 
  && (retry < _maxRetries),
	retry++;
);
//if retry==_maxRetries, force a failure
If(retry==_maxRetries, 
  $LOG.level=LOG_level;
  RunScript("<TAG>Scripts/Handlers/Event</TAG>",2,"Critical",
    event="Failed to read cache variable "+Quote(_name)+" in "+_maxRetries+" attempts.",true);
  RaiseError(event);
,
  RunScript("<TAG>Scripts/Handlers/Event</TAG>",6,"Current value of"
    +Quote(_name),value+" (Expires in: "+_expire+" secs) Scope: "+_scope);
  $LOG.level=LOG_level; value
)

Get Cloud Cache

LOG_level=$LOG.level; $LOG.level="Critical"; // so not as chatty
_name       = IfEmpty(_1,RaiseError("Read cache with no variable name provided"));
defaultExpire = Long(2592000);
_expire     = IfEmpty(_2,RunScript("<TAG>Scripts/Handlers/Event</TAG>",7,
  "Get Cloud Cache: Using expiration of the cached value for",_name);-1);
_scope      = IfEmpty(_3,"project"); //RunScript("<TAG>Scripts/Handlers/Event</TAG>",7,
//  "Get Cloud Cache: Using Cloud Cache 'project' scope for "+_name,Quote('project')); "project");
_maxRetries = IfEmpty(_4, 5);

retry=0; While( (
  Eval(

    value = ReadCache(_name,_expire,_scope), 

    "ERROR"
  ) == "ERROR") 
    && (retry < _maxRetries),
  retry++;
);
//if retry=_maxRetries, force a failure
If(retry==_maxRetries, 
  RunScript("<TAG>Scripts/Handlers/Event</TAG>",2,"Critical",
    event="Failed to read cache variable "+Quote(_name)+" in "+_maxRetries+" attempts.",true);
  RaiseError(event);
,
  $LOG.level=LOG_level; value
)