Key-Value Storage Service
Store, retrieve, and manage data in a powerful Key-Value database based on the Redis database.
This service support most of the powerful Redis commands.
IMPORTANT: Redis work with data in-memory and persists data every seconds. So an outage has the potential of loosing the last second of data. Therefore if you use this service to store critical data, you MUST implement an handshake to verify data is accessible (GET) after 1 second before considering the write successfull.
Operations
Keys
- Keystore.clear() - Remove all keys from this solution
- Keystore.delete() - Delete a key-value
- Keystore.get() - Get a key-value
- Keystore.list() - Get namespace keys
- Keystore.mdelete() - Delete keys
- Keystore.mget() - Get multiple keys
- Keystore.mset() - Set multiple values
- Keystore.set() - Set the value of a key
Settings
- Keystore.info() - Get namespace information
Other
- Keystore.command() - Execute a Redis command
Operations
Please note that bold arguments are required, while italic arguments are optional.
clear
Remove all keys from this solution namespace. Be careful. There is no going back!
Arguments
parameters (object) - Object containing service call parameters.
| Name | Type | Description |
|---|---|---|
| match | string | A filter to only return keys containing the matching string. The match filter is case-sensitive. |
| cursor | string | A pagination cursor to use if there are too many keys to return in a single call. |
| count | integer | Suggested number of elements to return in a single call. The actual number of elements returned could be more or less than the suggested amount. The default value is 1000, which is also the largest value allowed. |
Responses
| Code | Body Type | Description |
|---|---|---|
| 204 | nil | All solution keys successfully removed |
| default | object | Error |
Object Parameter of default response:
| Name | Type | Description |
|---|---|---|
| type | string | Error type |
| error | string | Error message |
| status | integer | Response code |
Example
delete
Remove a key-value from the store.
Arguments
parameters (object) - Object containing service call parameters.
| Name | Type | Description |
|---|---|---|
| key | string | Key id |
Responses
| Code | Body Type | Description |
|---|---|---|
| 204 | nil | Key successfully deleted |
| default | object | Error |
Object Parameter of default response:
| Name | Type | Description |
|---|---|---|
| type | string | Error type |
| error | string | Error message |
| status | integer | Response code |
Example
get
Return the value of the given key.
Arguments
parameters (object) - Object containing service call parameters.
| Name | Type | Description |
|---|---|---|
| key | string | Key id |
Responses
| Code | Body Type | Description |
|---|---|---|
| 200 | object | Key value successfully retrieved |
| default | object | Error |
Object Parameter of 200 response:
| Name | Type | Description |
|---|---|---|
| value | array, object, string, number, boolean, null | Key content |
Object Parameter of default response:
| Name | Type | Description |
|---|---|---|
| type | string | Error type |
| error | string | Error message |
| status | integer | Response code |
Example
list
Returns namespace keys and a pagination cursor. If list call returns non 0 for the cursor it means there are more keys avaliable. Pass the cursor to a second call to list to get the next page.
Arguments
parameters (object) - Object containing service call parameters.
| Name | Type | Description |
|---|---|---|
| match | string | A filter to only return keys containing the matching string. The match filter is case-sensitive. |
| cursor | string | A pagination cursor to use if there are too many keys to return in a single call. |
| count | integer | Suggested number of elements to return in a single call. The actual number of elements returned could be more or less than the suggested amount. The default value is 1000, which is also the largest value allowed. |
Responses
| Code | Body Type | Description |
|---|---|---|
| 200 | object | Namespace active keys |
| default | object | Error |
Object Parameter of 200 response:
| Name | Type | Description |
|---|---|---|
| keys | [ string ] | Active namespace keys |
| cursor | string | Pagination cursor |
Object Parameter of default response:
| Name | Type | Description |
|---|---|---|
| type | string | Error type |
| error | string | Error message |
| status | integer | Response code |
Example
local keys = {}
cursor = "0"
repeat
-- Be aware of excessive memory usage if your keyspace is large.
local res = Keystore.list({match = "*", cursor = cursor})
for _, k in ipairs(res.keys) do
table.insert(keys, k)
end
cursor = res.cursor
until(cursor == "0")
return keys
mdelete
Remove multiple keys-value from the store and return the number of removed keys.
Arguments
parameters (object) - Object containing service call parameters.
| Name | Type | Description |
|---|---|---|
| keys | [ string {1..200} ] {..100} | List of Keys |
Responses
| Code | Body Type | Description |
|---|---|---|
| 200 | object | Multi-delete response |
| default | object | Error |
Object Parameter of 200 response:
| Name | Type | Description |
|---|---|---|
| removed | integer | Number of new keys removed to the namespace. |
Object Parameter of default response:
| Name | Type | Description |
|---|---|---|
| type | string | Error type |
| error | string | Error message |
| status | integer | Response code |
Example
mget
Returns the values of the multiple given keys.
Arguments
parameters (object) - Object containing service call parameters.
| Name | Type | Description |
|---|---|---|
| keys | [ string {1..200} ] {..100} | List of Keys |
Responses
| Code | Body Type | Description |
|---|---|---|
| 200 | object | The response object containing the key values. |
| default | object | Error |
Object Parameter of 200 response:
| Name | Type | Description |
|---|---|---|
| values | [ array, object, string, number, boolean, null ] | Keys values data |
Object Parameter of default response:
| Name | Type | Description |
|---|---|---|
| type | string | Error type |
| error | string | Error message |
| status | integer | Response code |
Example
local map = Keystore.mset({ keys = {"key1", "key2"}, values = {"value1", "value2"} })
local result = Keystore.mget({ keys = {"key1", "key2"}})
print(result.values)
mset
Set or update multiple keys.
Arguments
parameters (object) - Object containing service call parameters.
| Name | Type | Description |
|---|---|---|
| keys | [ string {1..200} ] {..100} | List of Keys |
| values | [ string, number, boolean, null ] | Values to set in related keys. This array length MUST match the key length. |
Responses
| Code | Body Type | Description |
|---|---|---|
| 200 | object | Multi-Set response |
| default | object | Error |
Object Parameter of 200 response:
| Name | Type | Description |
|---|---|---|
| added | integer | Number of new keys added to the namespace. |
Object Parameter of default response:
| Name | Type | Description |
|---|---|---|
| type | string | Error type |
| error | string | Error message |
| status | integer | Response code |
Example
local map = Keystore.mset({ keys = {"key1", "key2"}, values = {"value1", "value2"} })
local result = Keystore.mget({ keys = {"key1", "key2"}})
print(result.values)
set
Set or update a key value. The value size cannot exceed 100kb.
Arguments
parameters (object) - Object containing service call parameters.
| Name | Type | Description |
|---|---|---|
| key | string | Key id |
| value | string, number, boolean, null | Key content |
Responses
| Code | Body Type | Description |
|---|---|---|
| 204 | nil | Key successfully set |
| default | object | Error |
Object Parameter of default response:
| Name | Type | Description |
|---|---|---|
| type | string | Error type |
| error | string | Error message |
| status | integer | Response code |
Example
info
Returns namespace information including usage.
Responses
| Code | Body Type | Description |
|---|---|---|
| 200 | object | Namespace information including usage |
| default | object | Error |
Object Parameter of 200 response:
| Name | Type | Description |
|---|---|---|
| quota | object | DEPRECATED, structure kept for backwared compatibility only |
| usage | object | Namespace usage |
| usage.keys | integer | Current number of keys being used by the solution namespace. |
Object Parameter of default response:
| Name | Type | Description |
|---|---|---|
| type | string | Error type |
| error | string | Error message |
| status | integer | Response code |
Example
command
This function offers some popular Redis commands to execute on the key. Please refer to http://redis.io/commands documentation page for the command information and parameters.
Arguments
parameters (object) - Object containing service call parameters.
| Name | Type | Description |
|---|---|---|
| key | string | Key id |
| command | "get", "set", "setnx", "getset", "del", "type", "exists", "strlen", "append", "getrange", "setrange", "bitcount", "bitpos", "getbit", "setbit", "incr", "incrby", "decr", "decrby", "incrbyfloat", "setex", "psetex", "expire", "pexpireat", "pexpire", "expireat", "pttl", "ttl", "persist", "lpush", "lpushx", "lindex", "llen", "linsert", "lrange", "lrem", "lset", "ltrim", "lpop", "rpop", "rpush", "rpushx", "sadd", "srem", "scard", "smembers", "sismember", "srandmember", "spop", "sscan", "hset", "hsetnx", "hdel", "hexists", "hget", "hgetall", "hincrby", "hincrbyfloat", "hkeys", "hlen", "hmget", "hmset", "hstrlen", "hvals", "hscan", "zadd", "zcard", "zincrby", "zcount", "zlexcount", "zrange", "zrangebylex", "zrangebyscore", "zrank", "zrem", "zremrangebylex", "zremrangebyscore", "zremrangebyrank", "zrevrange", "zrevrangebylex", "zrevrangebyscore", "zrevrank", "zscore", "zscan", "geoadd", "geohash", "geopos", "geodist", "georadius", "georadiusbymember" | This function offers some popular Redis commands to execute on the key. Please refer to http://redis.io/commands documentation page for the command information and parameters. |
| args | [ string, number, boolean ] | List of arguments for the specified command. Please refer to http://redis.io/commands documentation page for the command information and parameters. |
Responses
| Code | Body Type | Description |
|---|---|---|
| 200 | object | Command successfully executed |
| default | object | Error |
Object Parameter of 200 response:
| Name | Type | Description |
|---|---|---|
| value | array, object, string, number, boolean, null | Key content |
Object Parameter of default response:
| Name | Type | Description |
|---|---|---|
| type | string | Error type |
| error | string | Error message |
| status | integer | Response code |
Example
-- Add a string to a list
result = Keystore.command({
key = "myList",
command = "lpush",
args = {"oneItem"}
})
-- Retrieve the list content
result = Keystore.command({
key = "myList",
command = "lrange",
args = {0, -1}
})
Service Health Check
Operations
/health
Enable the hosting system to check if service is active and running
Arguments
No Content
Responses
| Name | Type | Description |
|---|---|---|
| 200 | string | OK |
Errors
No content