Commit 6c555283 authored by Marc Gravell's avatar Marc Gravell

Merge pull request #2 from matteobaglini/patch-2

Fix command
parents a92d7ff3 44d2409c
...@@ -8,7 +8,7 @@ A transaction in redis consists of a block of commands placed between `MULTI` an ...@@ -8,7 +8,7 @@ A transaction in redis consists of a block of commands placed between `MULTI` an
has been encountered, the commands on that connection *are not executed* - they are queued (and the caller gets the reply `QUEUED` has been encountered, the commands on that connection *are not executed* - they are queued (and the caller gets the reply `QUEUED`
to each). When an `EXEC` is encountered, they are to each). When an `EXEC` is encountered, they are
all applied in a single unit (i.e. without other connections getting time betweeen operations). If a `DISCARD` is seen instead of all applied in a single unit (i.e. without other connections getting time betweeen operations). If a `DISCARD` is seen instead of
a `MULTI`, everything is thrown away. Because the commands inside the transaction are queued, you can't make decisions *inside* a `EXEC`, everything is thrown away. Because the commands inside the transaction are queued, you can't make decisions *inside*
the transaction. For example, in a SQL database you might do the following (pseudo-code - illustrative only): the transaction. For example, in a SQL database you might do the following (pseudo-code - illustrative only):
// assign a new unique id only if they don't already // assign a new unique id only if they don't already
...@@ -103,4 +103,4 @@ This can be used in StackExchange.Redis via: ...@@ -103,4 +103,4 @@ This can be used in StackExchange.Redis via:
var wasSet = (bool) db.ScriptEvaluate(@"if redis.call('hexists', KEYS[1], 'UniqueId') then return redis.call('hset', KEYS[1], 'UniqueId', ARGV[1]) else return 0 end", var wasSet = (bool) db.ScriptEvaluate(@"if redis.call('hexists', KEYS[1], 'UniqueId') then return redis.call('hset', KEYS[1], 'UniqueId', ARGV[1]) else return 0 end",
new RedisKey[] { custKey }, new RedisValue[] { newId }); new RedisKey[] { custKey }, new RedisValue[] { newId });
(note that the response from `ScriptEvaluate` and `ScriptEvaluateAsync` is variable depending on your exact script; the response can be interpreted by casting - in this case as a `bool`) (note that the response from `ScriptEvaluate` and `ScriptEvaluateAsync` is variable depending on your exact script; the response can be interpreted by casting - in this case as a `bool`)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment