memcache@v1
Key/value store for short term storage.
| Version | memcache@v1 |
| Runs in | inbound-call and your own branches · api-initiated and inbound-sms · hangup, postHangup and events.ready |
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
command | get, set | |||
key | string | 1..255 characters | ||
value | any | |||
ttl | integer | 3600 | 1..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.valueexample: store a variable shared with a specific scenario
branches:
inbound-call:
actions:
- action: memcache@v1
params:
command: set
key: scenario-${{ scenario.sid }}
value: mydataResult
Set result: $myVariable to keep it.
| Field | Type | Description |
|---|---|---|
ok | boolean | true when the command succeeded (get: the key exists) |
value | any | get: the stored value (null when the key is not found). set: the value stored |
ttl | integer | set only: time to live of the key, in seconds |
error | string | Only 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
}
}Updated about 3 hours ago
Did this page help you?
