Skip to content

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:

{ "data": { ... } }

On error:

{ "error": { "code": "string", "message": "string" } }

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 plugins table (SELECT enabled ... WHERE id = 'redis').
  • Runs redis-cli CONFIG GET <key> for each inspected key (read-only).

Example

curl -X GET https://panel.example.com:2087/api/redis/config \
  -H "Authorization: Bearer $TOKEN"

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

{ "key": "string (required)", "value": "string (required)" }
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/missing key not in the allow-list yields invalid_key.

Response - 200 OK

{ "success": true }

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 plugins table.
  • Runs redis-cli CONFIG SET <key> <value>.
  • Runs redis-cli CONFIG REWRITE to persist to redis.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

{ "success": true, "message": "All keys flushed" }

Errors

Status Code Meaning
400 plugin_disabled The redis plugin is not enabled.
500 redis_error redis-cli FLUSHALL failed.

Side effects

  • Reads the plugins table.
  • Runs redis-cli FLUSHALL, irreversibly deleting all cached data.

Example

curl -X POST https://panel.example.com:2087/api/redis/flush \
  -H "Authorization: Bearer $TOKEN"

POST /api/redis/reset-stats

Resets Redis server statistics counters via redis-cli CONFIG RESETSTAT.

Guards: RequirePermission(db, "administrative_operations")

Response - 200 OK

{ "success": true, "message": "Statistics reset" }

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 plugins table.
  • 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

{ "success": true, "message": "Redis restarted" }

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 plugins table.
  • Runs systemctl restart redis, then systemctl restart redis-server if the first fails. Restarting flushes in-memory state not yet persisted.

Example

curl -X POST https://panel.example.com:2087/api/redis/restart \
  -H "Authorization: Bearer $TOKEN"

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_ratio is a percentage (hits / (hits + misses) * 100), or 0.0 when there have been no hits or misses. total_keys is parsed from the db0 keyspace 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 plugins table.
  • Runs redis-cli INFO (read-only).

Example

curl -X GET https://panel.example.com:2087/api/redis/stats \
  -H "Authorization: Bearer $TOKEN"

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

{ "plugin_enabled": true, "running": true }

running is determined by systemctl is-active redis, falling back to systemctl is-active redis-server. Unlike the other handlers, this endpoint does not return plugin_disabled when the plugin is off - it reports plugin_enabled: false instead.

Side effects

  • Reads the plugins table.
  • Runs systemctl is-active redis and/or systemctl is-active redis-server (read-only).

Example

curl -X GET https://panel.example.com:2087/api/redis/status \
  -H "Authorization: Bearer $TOKEN"