Key-Value Storage Service
Store, retrieve, and manage configuration or associative data in a powerful Key-Value database
Use it to safely store your configuration variables, logs, and much more. Based on the Redis database, this service provides many of the powerful Redis commands.
Important: The number of keys you can use is limited and depends on your West Connectivity Business tier. Use the info operation to see your current usage. Read more on themetrics-with-keystore
service guide page on the West Connectivity platform documentation site.
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. This operation frees a quota count for your namespace.
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. This operation free quota count for your namespace.
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. This operation will increase your usage count.
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 |
429 | nil | Namespace, Key count quota reached. Delete some un-used keys or contact West Connectivity team for upgrading your plan. You can view your current namespace usage with the list operation or on your West Connectivity portal account. |
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. If the key does not exist, this operation will increase your usage count. 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 |
429 | nil | Namespace, Key count quota reached. Delete some unused keys or contact West Connectivity team for upgrading your plan. You can view your current namespace usage with the info operation or on your West Connectivity portal account. |
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 and quota.
Responses
Code | Body Type | Description |
---|---|---|
200 | object | Namespace information including usage and quota |
default | object | Error |
Object Parameter of 200 response:
Name | Type | Description |
---|---|---|
quota | object | Usage limitation applying to this service |
quota.keys | integer | Maximum number of keys allowed for this solution depending on your West Connectivity plan. Contact West Connectivity team for more information. |
usage | object | Namespace usage |
usage.keys | integer | Current number of keys being used by the solution namespace. |
usage.size | integer | Total data size of solution namespace in bytes. |
Object Parameter of default response:
Name | Type | Description |
---|---|---|
type | string | Error type |
error | string | Error message |
status | integer | Response code |
Example
local result = Keystore.info()
print("I am using " .. result.usage.keys .. " out of my " .. result.quota.keys .. " keys")
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. Remember, some commands will increase your namespace usage and may hit your namespace quota. Not all Redis commands are supported. Please refer to the command parameter information below for the available functions.
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 |
429 | nil | Namespace, Key count quota reached. Delete some un-used keys or contact West Connectivity team for upgrading your plan. You can view your current namespace usage with the list operation or on your West Connectivity portal account. |
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