-
Notifications
You must be signed in to change notification settings - Fork 554
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use it in test custom transaction (stored proc)
- Loading branch information
Showing
6 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
using Garnet.common; | ||
using Garnet.server; | ||
using Tsavorite.core; | ||
|
||
namespace Garnet | ||
{ | ||
sealed class SortedSetCountTxn : CustomTransactionProcedure | ||
{ | ||
public override bool Prepare<TGarnetReadApi>(TGarnetReadApi api, ref CustomProcedureInput input) | ||
{ | ||
int offset = 0; | ||
AddKey(GetNextArg(ref input, ref offset), LockType.Exclusive, true); | ||
return true; | ||
} | ||
|
||
public override unsafe void Main<TGarnetApi>(TGarnetApi api, ref CustomProcedureInput input, ref MemoryResult<byte> output) | ||
{ | ||
int offset = 0; | ||
var key = GetNextArg(ref input, ref offset); | ||
var minScore = GetNextArg(ref input, ref offset); | ||
var maxScore = GetNextArg(ref input, ref offset); | ||
|
||
var status = api.SortedSetCount(key, minScore, maxScore, out int numElements); | ||
|
||
WriteSimpleString(ref output, numElements.ToString()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters