-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* PrepareScript should work for parameterless scripts; fix #2164 * update link in release notes * tyop
- Loading branch information
Showing
3 changed files
with
65 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
namespace StackExchange.Redis.Tests.Issues | ||
{ | ||
public class Issue2164 | ||
{ | ||
[Fact] | ||
public void LoadSimpleScript() | ||
{ | ||
LuaScript.Prepare("return 42"); | ||
} | ||
[Fact] | ||
public void LoadComplexScript() | ||
{ | ||
LuaScript.Prepare(@" | ||
------------------------------------------------------------------------------- | ||
-- API definitions | ||
------------------------------------------------------------------------------- | ||
local MessageStoreAPI = {} | ||
MessageStoreAPI.confirmPendingDelivery = function(smscMessageId, smscDeliveredAt, smscMessageState) | ||
local messageId = redis.call('hget', ""smId:"" .. smscMessageId, 'mId') | ||
if not messageId then | ||
return nil | ||
end | ||
-- delete pending delivery | ||
redis.call('del', ""smId:"" .. smscMessageId) | ||
local mIdK = 'm:'..messageId | ||
local result = redis.call('hsetnx', mIdK, 'sState', smscMessageState) | ||
if result == 1 then | ||
redis.call('hset', mIdK, 'sDlvAt', smscDeliveredAt) | ||
redis.call('zrem', ""msg.validUntil"", messageId) | ||
return redis.call('hget', mIdK, 'payload') | ||
else | ||
return nil | ||
end | ||
end | ||
------------------------------------------------------------------------------- | ||
-- Function lookup | ||
------------------------------------------------------------------------------- | ||
-- None of the function calls accept keys | ||
if #KEYS > 0 then error('No Keys should be provided') end | ||
-- The first argument must be the function that we intend to call, and it must | ||
-- exist | ||
local command_name = assert(table.remove(ARGV, 1), 'Must provide a command as first argument') | ||
local command = assert(MessageStoreAPI[command_name], 'Unknown command ' .. command_name) | ||
return command(unpack(ARGV))"); | ||
} | ||
} | ||
} |