memcache@v1

Key/value store for short term storage.

Versionmemcache@v1
Runs ininbound-call and your own branches · api-initiated and inbound-sms · hangup, postHangup and events.ready

Parameters

NameTypeRequiredDefaultDescription
commandget, set
keystring1..255 characters
valueany
ttlinteger36001..3600 · accepts ${{ }}

Every parameter that accepts ${{ }} can be computed from an expression.

How it works

Keys are sandboxed to your account. This means that keys are SHARED between calls, SMS, and API-initiated actions. To avoid conflicts, you should prefix your keys with a unique identifier.

Examples

example: store the history of inbound SMS per sender

branches:
  inbound-sms:
    actions:
      - action: memcache@v1
        params:
          command: get
          key: history-${{ sms.from }} # unique key per sender
        result: $cache

      - if: $cache.ok
        then:
          - action: javascript@v1
            params:
              code: $history = $cache.value

example: store a variable shared with a specific scenario

branches:
  inbound-call:
    actions:
      - action: memcache@v1
        params:
          command: set
          key: scenario-${{ scenario.sid }}
          value: mydata

Result

Set result: $myVariable to keep it.

FieldTypeDescription
okbooleantrue when the command succeeded (get: the key exists)
valueanyget: the stored value (null when the key is not found). set: the value stored
ttlintegerset only: time to live of the key, in seconds
errorstringOnly when ok is false: key not found, no command specified, no key specified, key must be a string, no value specified, invalid command
{
  "ok": true,
  "value": {
    "visits": 3
  }
}

Did this page help you?