setnx

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

[Redis documentation]


Query Syntax

HTTP

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

Other protocols

Copied to clipboard!
{
  "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).

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