Core
API v2.x
2

setnx #

Sets a value on a key, only if it does not already exist.

[Redis documentation]


Query Syntax #

HTTP #

URL: http://kuzzle:7512/ms/_setnx/<_id>
Method: POST
Body:
{
  "value": "<value>"
}

Other protocols #

{
  "controller": "ms",
  "action": "setnx",
  "_id": "<key>",
  "body": {
    "value": "<value>"
  }
}

Argument #

  • _id: key identifier

Body properties #

  • value: new key value

Response #

Returns either 0 (command failed), or 1 (command succeeded).

{
  "requestId": "<unique request identifier>",
  "status": 200,
  "error": null,
  "controller": "ms",
  "action": "setnx",
  "collection": null,
  "index": null,
  "result": 1
}