Accessor: net/KeyValueStore


This accessor reads or writes data to a key-value store web service whenever it receives a trigger input. A URL for the service is specified by the storeLocation parameter. A Ptolemy II model that provides such a key-value store service can be found at A demo client that uses this accessor is provided at

The key and the value are both text items provided as inputs. If remove is true and the key is non-empty, then upon firing, this actor will remove the specified key from the store, producing on its output the previous value (if any). If remove is false, then this actor will either set or retrieve a value in the key-value store, depending on whether the value input is non-empty. If the value is non-empty, then this actor sets the value for the specified key. If it is empty, then this actor retrieves the value for the specified key. If no key is given, then this actor retrieves an array of all the keys in the key-value store.

If an error occurs accessing the key-value store (e.g., no store is found at the specified URL, or no value is found with the specified key), then an exception is thrown.

This accessor assumes that the protocol implemented at that location matches the specification below for the default location:

  • To store a value with key MY_ID and value MY_VALUE, use


  • To retrieve the value, use


  • To remove a value, use


  • To list all the keys, use


    The key and value are both encoded using the JavaScript encodeURIComponent() function, and on retrieval, decoded using decodeURIComponent(), and hence can include any text characters.

    Note that this accessor uses nonblocking reads to access the store, so the output is produced later when the server responds.

  • $$Id$$
  • Edward A. Lee
Name Type Description
storeLocation string The URL of the key-value store service.
key string The key to be updated or retrieved.
remove boolean If true, then remove the key from the store; otherwise, retrieve the value for the key.
value string The value to store in the key-value store, or empty to not store anything.
trigger The trigger input.
Name Type Description
result string The value retrieved from or written to the key-value store.