Redis¶
Redis status and basic stats.
All endpoints below are mounted under /api. Authentication: Authorization: Bearer <token> unless noted as public.
Endpoint count: 7
Endpoints¶
| Method | Path | Handler | Guards |
|---|---|---|---|
GET |
/api/redis/config |
getRedisConfig |
RequirePermission(db, "administrative_operations") |
POST |
/api/redis/config |
setRedisConfig |
RequirePermission(db, "administrative_operations") |
POST |
/api/redis/flush |
redisFlushAll |
RequirePermission(db, "administrative_operations") |
POST |
/api/redis/reset-stats |
redisResetStats |
RequirePermission(db, "administrative_operations") |
POST |
/api/redis/restart |
redisRestart |
RequirePermission(db, "administrative_operations") |
GET |
/api/redis/stats |
getRedisStats |
RequirePermission(db, "administrative_operations") |
GET |
/api/redis/status |
getRedisStatus |
RequirePermission(db, "administrative_operations") |
Source¶
Handlers for this section live in api/routes/handlers_*.go in the StarkOne source. Each handler binds its request body with gin.ShouldBindJSON(&req) and responds with the standard envelope:
On error:
Note: The Redis handlers in this section return flat (non-enveloped) JSON bodies (e.g.
{ "running": true },{ "stats": {...} },{ "config": {...} },{ "success": true }) rather than the standard{ "data": {...} }envelope. Error responses do use the{ "error": { "code", "message" } }shape.
Reference¶
GET /api/redis/config¶
Returns selected Redis configuration values (memory, network, auth) and the detected persistence mode by querying redis-cli CONFIG GET.
Guards: RequirePermission(db, "administrative_operations")
Response - 200 OK
The config object contains whichever of these keys redis-cli returns: maxmemory, maxmemory-policy, bind, port, requirepass, plus a derived persistence value (none, rdb, aof, or both).
{
"config": {
"maxmemory": "0",
"maxmemory-policy": "noeviction",
"bind": "127.0.0.1",
"port": "6379",
"requirepass": "",
"persistence": "rdb"
}
}
Errors
| Status | Code | Meaning |
|---|---|---|
400 |
plugin_disabled |
The redis plugin row in the plugins table is not enabled. |
Side effects
- Reads the
pluginstable (SELECT enabled ... WHERE id = 'redis'). - Runs
redis-cli CONFIG GET <key>for each inspected key (read-only).
Example
POST /api/redis/config¶
Sets a single allowed Redis configuration key via redis-cli CONFIG SET and persists it to redis.conf with CONFIG REWRITE.
Guards: RequirePermission(db, "administrative_operations")
Request body
| Field | Type | Required | Description |
|---|---|---|---|
key |
string | yes | Config key to set. Must be one of: maxmemory, maxmemory-policy, requirepass, bind, port. |
value |
string | yes | New value for the key. |
Required-ness is enforced by allow-list/validation logic, not by
binding:"required"struct tags. An empty/missingkeynot in the allow-list yieldsinvalid_key.
Response - 200 OK
Errors
| Status | Code | Meaning |
|---|---|---|
400 |
plugin_disabled |
The redis plugin is not enabled. |
400 |
bad_request |
Request body could not be parsed as JSON. |
400 |
invalid_key |
key is not in the allowed set. |
500 |
redis_error |
redis-cli CONFIG SET failed. |
Side effects
- Reads the
pluginstable. - Runs
redis-cli CONFIG SET <key> <value>. - Runs
redis-cli CONFIG REWRITEto persist toredis.conf(errors ignored).
Example
curl -X POST https://panel.example.com:2087/api/redis/config \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"key": "maxmemory-policy", "value": "allkeys-lru"}'
POST /api/redis/flush¶
Deletes all keys from all Redis databases by running redis-cli FLUSHALL.
Guards: RequirePermission(db, "administrative_operations")
Response - 200 OK
Errors
| Status | Code | Meaning |
|---|---|---|
400 |
plugin_disabled |
The redis plugin is not enabled. |
500 |
redis_error |
redis-cli FLUSHALL failed. |
Side effects
- Reads the
pluginstable. - Runs
redis-cli FLUSHALL, irreversibly deleting all cached data.
Example
POST /api/redis/reset-stats¶
Resets Redis server statistics counters via redis-cli CONFIG RESETSTAT.
Guards: RequirePermission(db, "administrative_operations")
Response - 200 OK
Errors
| Status | Code | Meaning |
|---|---|---|
400 |
plugin_disabled |
The redis plugin is not enabled. |
500 |
redis_error |
redis-cli CONFIG RESETSTAT failed. |
Side effects
- Reads the
pluginstable. - Runs
redis-cli CONFIG RESETSTAT, clearing hit/miss and command counters.
Example
curl -X POST https://panel.example.com:2087/api/redis/reset-stats \
-H "Authorization: Bearer $TOKEN"
POST /api/redis/restart¶
Restarts the Redis service, trying the redis systemd unit first and falling back to redis-server.
Guards: RequirePermission(db, "administrative_operations")
Response - 200 OK
Errors
| Status | Code | Meaning |
|---|---|---|
400 |
plugin_disabled |
The redis plugin is not enabled. |
500 |
restart_error |
Both systemctl restart redis and systemctl restart redis-server failed. |
Side effects
- Reads the
pluginstable. - Runs
systemctl restart redis, thensystemctl restart redis-serverif the first fails. Restarting flushes in-memory state not yet persisted.
Example
GET /api/redis/stats¶
Returns parsed Redis runtime statistics (memory, clients, keys, hit ratio, uptime, commands, version) from redis-cli INFO.
Guards: RequirePermission(db, "administrative_operations")
Response - 200 OK
{
"stats": {
"used_memory": 1048576,
"used_memory_human": "1.00M",
"maxmemory": 0,
"maxmemory_human": "0B",
"maxmemory_policy": "noeviction",
"connected_clients": 1,
"total_keys": 42,
"keyspace_hits": 1000,
"keyspace_misses": 50,
"hit_ratio": 95.23809523809523,
"uptime_seconds": 3600,
"total_commands": 12345,
"redis_version": "7.0.0"
}
}
hit_ratiois a percentage (hits / (hits + misses) * 100), or0.0when there have been no hits or misses.total_keysis parsed from thedb0keyspace line.
Errors
| Status | Code | Meaning |
|---|---|---|
400 |
plugin_disabled |
The redis plugin is not enabled. |
500 |
redis_error |
redis-cli INFO failed. |
Side effects
- Reads the
pluginstable. - Runs
redis-cli INFO(read-only).
Example
GET /api/redis/status¶
Reports whether the Redis plugin is enabled and whether the Redis service is currently active.
Guards: RequirePermission(db, "administrative_operations")
Response - 200 OK
runningis determined bysystemctl is-active redis, falling back tosystemctl is-active redis-server. Unlike the other handlers, this endpoint does not returnplugin_disabledwhen the plugin is off - it reportsplugin_enabled: falseinstead.
Side effects
- Reads the
pluginstable. - Runs
systemctl is-active redisand/orsystemctl is-active redis-server(read-only).
Example