On this Page

    _cache (Scripting Object)

    Description

    The _cache object provides a way to store information at various points in a Merge run and retrieve it later on. The _cache data does not disappear between Merge events nor between Merge documents. Stored data is simply associated with a given name. _cache variables and their values are often defined via the -cache command line option. In JavaScript, you can assign a value to a cache variable either by directly assigning it to the variable as in:

    _cache.foo = "some value";

    or by using the _cache.set() function as in:

     _cache.set("foo", "some value");

    Similarly, you can retrieve values from _cache by:

    var value = _cache.foo;         // sets value to "some value"
    var value2 = _cache.get("foo"); // sets value2 to "some value"

    Embedded references can be made to _cache variables via the syntax [!Cache name], as in [!Cache foo] using the above example.

    Note _cache variables are always stored as strings. A side effect of that is that the + operator in JavaScript implies concatenation, not addition. It's likely that you may want to make liberal use of the construct parseInt(_cache.name). _cache variables are often used in counting operations; if you use the standard JavaScript notation of ++ that is recognized as an integer operation and the _cache variable will be automatically converted to a number before being incremented and then stored back as a string.

    _cache.counter = 0;  ...
    _cache.counter++;

    Advanced _cache usage

    Sometimes you wish to cache arrays of values. There are various techniques that you could use. The following is a rarely used method. It's rare because people rarely use _cache.set("name") when they can simply use _cache.name. However, there is the further option of:

    _cache.set("name", someValue, index);

    which lets you supply an array index, hence permitting the creation of an array of values. Naturally, there is the corresponding:

    _cache.get("name", index);

    to retrieve an array element.

    Functions

    _cache.logf()

    Dump _cache content to log file.

    _cache.get(name[,index])

    Get value of _cache property name.

    _cache.set(name,value[,index])

    Set _cache property name to value.

    _cacheInt(name[,index])

    Returns _cache property name as an integer.

    _cacheIncr(name[,index])

    Increments _cache property name by one. Returns incremented value.

    See Also

    Auto/Embedded Fields
    -cache - command-line option