REST API

Object Cache Pro provides several REST API endpoints. All endpoints, their arguments and properties are discoverable at /objectcache/v1/ with OPTIONS requests.

All endpoints require the objectcache_manage capability by default; see Authorization to change this.

Latency

Returns the latency of all connected servers and cluster nodes.

GET /objectcache/v1/latency

Response

[
  {
    "url": "tcp://127.0.0.1:6379",
    "latency": 150
  },
  {
    "url": "tcp://127.0.0.1:6380",
    "error": "read error on connection"
  }
]

Groups

Returns a list of currently stored cache groups.

GET /objectcache/v1/groups

Pass ?memory=1 to additionally compute the byte size of each group. Memory usage is not available on clustered connections.

Response

[
  { "group": "default", "keys": 42 },
  { "group": "options", "keys": 108 },
  { "group": "post_meta", "keys": 47 },
  { "group": "posts", "keys": 13 }
]

Flush group

Flushes the keys in a single cache group.

DELETE /objectcache/v1/groups?group=<group>

Analytics

Returns computed or raw analytics, depending on the given context. Supports pagination parameters, the global _fields parameter as well as an interval parameter.

GET /objectcache/v1/analytics

To discover all arguments and properties use an OPTIONS request:

curl -X OPTIONS "https://example.com/wp-json/objectcache/v1/analytics"

Response

[
  {
    "timestamp": 1649205350,
    "date_display": {
      "date": "Wed 6th",
      "time": "00:35 - 00:36 GMT+0000"
    },
    "hits": { "median": 1674 },
    "misses": { "median": 8 },
    "hit-ratio": { "median": 99.52 }
  }
]

Command statistics

Resets the server’s command statistics, equivalent to issuing CONFIG RESETSTAT.

DELETE /objectcache/v1/commands

Slow commands log

Resets the server’s slow commands log, equivalent to SLOWLOG RESET.

DELETE /objectcache/v1/slowlog

Options

Returns the plugin’s runtime options.

GET /objectcache/v1/options

Response

{
  "channel": "stable",
  "flushlog": true
}

To update the runtime options (such as the update channel or the flushlog):

POST /objectcache/v1/options
PUT /objectcache/v1/options
{ "channel": "beta" }

The available channel values come from the plugin’s release stabilities (e.g. stable, beta, alpha). Updating options requires the same capability as the read endpoint.

Relay adaptive cache

When Relay is in use, returns the per-key statistics of Relay’s adaptive cache (reads, writes, read/write ratio).

GET /objectcache/v1/relay/adaptive