Skip to content

Cache Endpoints

Cache management and statistics.

Get Stats

GET /cache/stats

Get cache statistics.

bash
curl http://localhost:3000/cache/stats \
  -H "Authorization: Bearer <token>"

Response:

json
{
  "provider": "redis",
  "size": 1234,
  "maxSize": 10000,
  "hits": 50000,
  "misses": 5000,
  "hitRate": 0.91,
  "memoryUsed": 52428800
}

List Keys

GET /cache/keys

List cached keys.

bash
curl "http://localhost:3000/cache/keys?pattern=*users*" \
  -H "Authorization: Bearer <token>"

Response:

json
{
  "keys": [
    "cache:users:list",
    "cache:users:123"
  ],
  "count": 2
}

Clear Cache

DELETE /cache/clear

Clear all cache.

bash
curl -X DELETE http://localhost:3000/cache/clear \
  -H "Authorization: Bearer <token>"

Response:

json
{
  "success": true,
  "cleared": 1234
}

DELETE /cache/key/:key

Delete specific key.

bash
curl -X DELETE http://localhost:3000/cache/key/cache:users:list \
  -H "Authorization: Bearer <token>"

Response:

json
{
  "success": true,
  "deleted": "cache:users:list"
}

DELETE /cache/pattern/:pattern

Delete keys by pattern.

bash
curl -X DELETE "http://localhost:3000/cache/pattern/cache:users:*" \
  -H "Authorization: Bearer <token>"

Response:

json
{
  "success": true,
  "deleted": 15
}

Cache Headers

Cached responses include:

X-Cache-Hit: true
X-Cache-TTL: 300

Released under the ISC License.