# Redis Key-value store with expiry, counters, and sorted sets. Execute commands over HTTP — no Redis client or TCP connection needed. ## Prerequisites Provision this resource before use. Edge requests without provisioning will error. ### Provision curl -s -X POST https://cohesivity.ai/api/resources/redis \ -H "Authorization: Bearer " ### Delete curl -s -X DELETE https://cohesivity.ai/api/resources/redis \ -H "Authorization: Bearer " **Important:** Provision this resource now, before building or running the application. Provisioning is the agent's job, not the application's. ## Edge Usage - **Base URL:** https://cohesivity.ai/edge/redis - **Auth:** `coh_application_key` as the **key** query parameter - **Method:** POST with JSON body `{ "command": "SET", "args": ["key", "value"] }` - **Response:** `{ "result": ... }` ## Supported Commands - **Key-value:** GET, SET, DEL, MGET, MSET, EXISTS, KEYS, TTL, TYPE - **Expiry:** EXPIRE, PEXPIRE, EXPIREAT, PERSIST - **Counters:** INCR, DECR, INCRBY, DECRBY, INCRBYFLOAT - **Sorted sets:** ZADD, ZREM, ZSCORE, ZRANK, ZRANGE, ZREVRANGE, ZRANGEBYSCORE, ZCARD, ZCOUNT, ZINCRBY All other commands are blocked. ## Examples - Set a key: `POST https://cohesivity.ai/edge/redis?key=` with `{ "command": "SET", "args": ["mykey", "myvalue"] }` - Get a key: `{ "command": "GET", "args": ["mykey"] }` → `{ "result": "myvalue" }` - Set with expiry: `{ "command": "SET", "args": ["session", "data"] }` then `{ "command": "EXPIRE", "args": ["session", "3600"] }` - Counter: `{ "command": "INCR", "args": ["visits"] }` → `{ "result": 1 }` - Sorted set: `{ "command": "ZADD", "args": ["leaderboard", "100", "alice", "200", "bob"] }` → `{ "result": 2 }` - Get range: `{ "command": "ZRANGE", "args": ["leaderboard", "0", "-1", "WITHSCORES"] }` → `{ "result": ["alice", "100", "bob", "200"] }` - Multiple keys: `{ "command": "MSET", "args": ["a", "1", "b", "2"] }` → `{ "result": "OK" }` - Get multiple: `{ "command": "MGET", "args": ["a", "b"] }` → `{ "result": ["1", "2"] }` - List keys: `{ "command": "KEYS", "args": ["*"] }` → `{ "result": ["mykey", "session", "visits", ...] }` - Delete: `{ "command": "DEL", "args": ["mykey"] }` → `{ "result": 1 }`