通过支持 HTTP 协议客户端请求: http://lcoahsot:2468

下面为 string 的POST:

{
    "type": "string",
    "insert": [
        // 设置对于的值和超时时间
        {"key": "key01","value":"value","ttl":200},
        {"key": "key01","value":2020,"ttl":200}
    ]
}

下面为删除 string 类型的操作:

{
    "type": "string",
    "delete": [
        // 删除指定的 key
        "key01",
        "ley02"
    ]
}

下面为 string 类型更新操作:

{
    "type": "string",
    "update": [
        // 更新对应的值
        {"key01":"value01"},
        {"key02":"value02"}
    ]
}

下面获取 string 值操作:

{
    "type": "string",
    "query": [
        // 查询对应的值
        {"key01":"value01"},
        {"key02":"value02"}
    ]
}

下面为 LIST 的POST:

{
    "type": "list",
    "insert": [
         // 向 key01 列表中添加元素,默认从右插入
        {"key": "key01","value": [1,2,3,4,5,6],"ttl":200},
        {"key": "key01","value": ["Hello"],"ttl":200}
    ]
}

同样支持从头部插入,还是从尾部插入:

{
    "type": "list",
    "insert": [
        // 向 key01 列表中添加元素,从右插入
        {"key": "key01","value": [7,8,9,10,11,12],"opt":"lpush","ttl":200},
         // 向 key01 列表中添加元素,从左插入
        {"key": "key01","value": ["World"],"opt":"rpush","ttl":200}
    ]
}

获取 LIST 元素支持范围查询:

{
    "type": "list",
    "query": [
        // 返回 key01 集合中元素按照索引取区间
        {"key": "key01","range":"5-8"},
        // 返回 key02 集合中元素按照索引取 0 号元素
        {"key": "key02","index":0}
    ]
}

下面为 SET 的POST:

{
    "type": "set",
    "insert": [
        // 插入元素到 key01 集合中,默认从右插入
        {"key": "key01","value": ["s1","s2","s3"],"ttl":200},
        {"key": "key01","value": ["s4","s6"],"ttl":200}
    ]
}

下面为 ZSET 的POST:

{
    "type": "zset",
    "insert": [
        // 为 key01 集合中添加元素和对应分数
        {"key": "key01","score": 100 ,"value":"Java","ttl":200},
        {"key": "key01","score": 200 ,"value":"Go","ttl":200},
        {"key": "key01","score": 300 ,"value":"JS","ttl":200}
    ]
}

同样更新 ZSET 的操作如下:

{
    "type": "zset",
    "update": [
        // 更新 key01 集合成员 Java 的分数值
        {"key": "key01","score": 900 ,"value":"Java"}
    ]
}

同样查询操作:

{
    "type": "zset",
    "query": [
        // 返回 value01 集合索引为 10 的元素
        {"key":"value01","index":10},
        // 返回 value02 集合按照索引取区间
        {"key":"value02","range":"1-5"},
        // 返回 value03 集合按照省序排序
        {"key":"value03","order":"asc"},
        // 返回 value04 集合按照降序排序
        {"key":"value04","order":"desc"},
        // 返回 value05 集合中的制定成员的分数
        {"key":"value05","score":"Leon"}
    ]
}

下面为 HASH 的POST:

{
    "type": "hash",
    "insert": [
        {
            "key": "p1",
            "value": [
                {
                    "name": "Leon"
                },
                {
                    "age": 23
                },
                {
                    "salary": 8000
                }
            ],
            "ttl": 200
        },
        {
            "key": "p1",
            "value": [
                {
                    "name": "Tom"
                },
                {
                    "age": 22
                }
            ],
            "ttl": 200
        }
    ]
}

查询 hash 中的值:

{
    "type": "hash",
    "query": [
        // 返回 p1 hash中的 name 字段的元素
        {"key":"p1","field":"name"}
    ]
}

更新 hash 中的值:

{
    "type": "hash",
    "update": [
        // 更新 p1 hash中的 name 字段的元素
        {"key":"p1","field":"name","value":"Leon Ding"}
    ]
}

下面为 Object 的POST:

{
    "type":"object",
    "alice":{
        "name": "Alice",
        "age": 30,
        "gender": "female",
        "occupation": "software engineer",
        "hobbies":[
            "reading",
            "hiking",
            "cooking"
        ],
        "contact":{
            "email": "[email protected]",
            "phone": "555-1234",
            "address":{
                "street": "123 Main St",
                "city": "Anytown",
                "state": "CA",
                "zip": "12345"
            }
        },
        "ttl": 200
    }
}

下面为 Script 的POST:

{
    "type": "script",
    "insert": [
        {
            "key": "action_fun",
            "object": "alice",
            "value": "function getAddressString(args) { let addressArr = []; for (let key in args.contact.address) { addressArr.push(args.contact.address[key]); } return addressArr.join(', '); }",
            "ttl": 200
        }
    ]
}

// GET: http://lcoahsot:2468/lambda/action_fun
// output:

{
    "status": "OK",
    "time": "0.34s",
    "result": "123 Main St, Anytown, CA, 12345"
}
便宜 VPS vultr
最后修改:2023 年 07 月 05 日
如果觉得我的文章对你有用,请随意赞赏 🌹 谢谢 !