ergm_state_cache | R Documentation |
This cache is intended to store large, infrequently changing data
structures such as ergm_model
s and ergm_proposal
s on worker
nodes.
ergm_state_cache(
comm = c("pass", "all", "clear", "insert", "get", "check", "list"),
key,
object
)
comm |
a character string giving the desired function; see the default argument above for permitted values and Details for meanings; partial matching is supported. |
key |
a character string, typically a |
object |
the object to be stored. Supported tasks are, respectively, to do nothing (the default), return all entries (mainly useful for testing), clear the cache, insert into cache, retrieve an object by key, check if a key is present, or list keys defined. Deleting an entry can be accomplished by inserting a Cache is limited to a hard-coded size (currently 4). This should
accommodate an |
If called via, say, clusterMap(cl, ergm_state_cache, ...)
the function will not accomplish anything. This is because
parallel
package will serialise the ergm_state_cache()
function object, send it to the remote node, evaluate it there,
and fetch the return value. This will leave the environment of
the worker's ergm_state_cache()
unchanged. To actually
evaluate it on the worker nodes, it is recommended to wrap it in
an empty function whose environment is set to globalenv()
. See
Examples below.
## Not run:
# Wrap ergm_state_cache() and call it explicitly from ergm:
call_ergm_state_cache <- function(...) ergm::ergm_state_cache(...)
# Reset the function's environment so that it does not get sent to
# worker nodes (who have their own instance of ergm namespace
# loaded).
environment(call_ergm_state_cache) <- globalenv()
# Now, call the the wrapper function, with ... below replaced by
# lists of desired arguments.
clusterMap(cl, call_ergm_state_cache, ...)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.