Local Storage
Store Key-Value pairs in the control box as strings.
Set Key-Value Pair
- Function name: Method
set_itemunder [Robot] - Parameters:
- key: [str] Key name
- value: [str] Value corresponding to the key
- Return: None
Example Program
lebai:set_item("key", "value")
lebai.set_item("key", "value")
JSON-RPC
// Request:
{ "jsonrpc": "2.0", "method": "set_item", "params": [{"key": "", "value": ""}], "id": 1 }
// Response:
{ "jsonrpc": "2.0", "result": {}, "id": 1 }
Get Key-Value Pair
- Function name: Method
get_itemunder [Robot] - Parameters:
- key: [str] Key name
- Return: [Item] Value corresponding to the key
Example Program
value = lebai:get_item("key")
print(value)
value = lebai.get_item("key")
print(value)
JSON-RPC
// Request:
{ "jsonrpc": "2.0", "method": "get_item", "params": [{"key": ""}], "id": 1 }
// Response:
{ "jsonrpc": "2.0", "result": {"value": ""}, "id": 1 }
Get All Key-Value Pairs with Specified Prefix
- Function name: Method
get_itemsunder [Robot] - Parameters:
- prefix: [str] Key name prefix
- Return: [Item] Key-value pair array
Example Program
values = lebai:get_items("prefix")
print(values)
values = lebai.get_items("prefix")
print(values)
JSON-RPC
// Request:
{ "jsonrpc": "2.0", "method": "get_items", "params": [{"perfix": ""}], "id": 1 }
// Response:
{ "jsonrpc": "2.0", "result": {"items": [{"key": "", "value": ""}]}, "id": 1 }
