Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
hamdaankhalidmsft committed Jan 29, 2025
1 parent 27fa4c7 commit c38526e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
4 changes: 2 additions & 2 deletions libs/resources/RespCommandsDocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -6163,7 +6163,7 @@
{
"Command": "SETIFGREATER",
"Name": "SETIFGREATER",
"Summary": "Sets the string value of a key, ignoring its type, if the key\u0027s current etag is strictly less than the given etag.",
"Summary": "Sets a key value pair using the given etag incremented only if (1) the etag given in the request is greater than the already existing etag ; or (2) the existing value was not associated with any etag and the given etag is more than 0.",
"Group": "String",
"Complexity": "O(1)",
"Arguments": [
Expand Down Expand Up @@ -6209,7 +6209,7 @@
]
}
]
}
},
{
"Command": "SETIFMATCH",
"Name": "SETIFMATCH",
Expand Down
3 changes: 2 additions & 1 deletion libs/server/Resp/BasicEtagCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ private bool NetworkSETIFMATCH<TGarnetApi>(ref TGarnetApi storageApi)

/// <summary>
/// SETIFGREATER key val etag [EX|PX] [expiry]
/// Sets a key value pair with the given ETag only if the already existing etag is less than the etag given in request.
/// Sets a key value pair using the given etag incremented only if (1) the etag given in the request is greater than the already existing etag ;
/// or (2) the existing value was not associated with any etag and the given etag is more than 0
/// </summary>
/// <typeparam name="TGarnetApi"></typeparam>
/// <param name="storageApi"></param>
Expand Down
2 changes: 1 addition & 1 deletion playground/CommandInfoUpdater/GarnetCommandsDocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@
{
"Command": "SETIFGREATER",
"Name": "SETIFGREATER",
"Summary": "Sets the string value of a key, ignoring its type, if the key\u0027s current etag is strictly less than the given etag.",
"Summary": "Sets a key value pair using the given etag incremented only if (1) the etag given in the request is greater than the already existing etag ; or (2) the existing value was not associated with any etag and the given etag is more than 0",
"Group": "String",
"Complexity": "O(1)",
"Arguments": [
Expand Down
28 changes: 26 additions & 2 deletions website/docs/commands/garnet-specific.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,31 @@ Garnet provides support for ETags on raw strings. By using the ETag-related comm
Compatibility with non-ETag commands and the behavior of data inserted with ETags are detailed at the end of this document.

To initialize a key value pair with an ETag you can use either the SET command with the newly added "WITHETAG" optional flag, or you can take any existing Key value pair and call SETIFMATCH with the ETag argument as 0 (Any key value pair without an explicit ETag has an ETag of 0 implicitly). **You can read more about setting an initial ETag via SET [here](../commands/raw-string#set)**
---

### **SET (WITHETAG)**

#### **Syntax**

```bash
SET key value [NX | XX] [EX seconds | PX milliseconds] [KEEPTTL] WITHETAG
```

Set **key** to hold the string value along with an ETag. If key already holds a value, it is overwritten, regardless of its type. Any previous time to live associated with the **key** is discarded on successful SET operation.

**Options:**

* EX seconds -- Set the specified expire time, in seconds (a positive integer).
* PX milliseconds -- Set the specified expire time, in milliseconds (a positive integer).
* NX -- Only set the key if it does not already exist.
* XX -- Only set the key if it already exists.
* KEEPTTL -- Retain the time to live associated with the key.
* WITHETAG -- **Adding this sets the Key Value pair with an initial ETag**, if called on an existing key value pair with an ETag, this command will update the ETag transparently.

#### Resp Reply

* Integer reply: WITHETAG given: The ETag associated with the value.


---

Expand Down Expand Up @@ -201,8 +226,7 @@ One of the following:
```bash
SETIFGREATER key value etag [EX seconds | PX milliseconds]
```

Updates the value of a key if the provided ETag is greater than the current ETag of the key.
Sets a key value pair using the given etag incremented only if (1) the etag given in the request is greater than the already existing etag ; or (2) the existing value was not associated with any etag and the given etag is more than 0.

**Options:**
* EX seconds -- Set the specified expire time, in seconds (a positive integer).
Expand Down

0 comments on commit c38526e

Please sign in to comment.