Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
StackExchange.Redis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
StackExchange.Redis
Commits
80dd68f6
Commit
80dd68f6
authored
Aug 17, 2018
by
Tomasz Żmuda
Committed by
Marc Gravell
Aug 17, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support count argument in SPOP (#918)
* Get multiple elements with SetPop * Adjust names
parent
7ec50486
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
58 additions
and
2 deletions
+58
-2
DatabaseWrapperTests.cs
StackExchange.Redis.Tests/DatabaseWrapperTests.cs
+8
-1
WrapperBaseTests.cs
StackExchange.Redis.Tests/WrapperBaseTests.cs
+8
-1
IDatabase.cs
...xchange.Redis/StackExchange/Redis/Interfaces/IDatabase.cs
+10
-0
IDatabaseAsync.cs
...ge.Redis/StackExchange/Redis/Interfaces/IDatabaseAsync.cs
+10
-0
DatabaseWrapper.cs
.../StackExchange/Redis/KeyspaceIsolation/DatabaseWrapper.cs
+5
-0
WrapperBase.cs
...edis/StackExchange/Redis/KeyspaceIsolation/WrapperBase.cs
+5
-0
RedisDatabase.cs
StackExchange.Redis/StackExchange/Redis/RedisDatabase.cs
+12
-0
No files found.
StackExchange.Redis.Tests/DatabaseWrapperTests.cs
View file @
80dd68f6
...
...
@@ -563,12 +563,19 @@ public void SetMove()
}
[
Fact
]
public
void
SetPop
()
public
void
SetPop
_1
()
{
wrapper
.
SetPop
(
"key"
,
CommandFlags
.
HighPriority
);
mock
.
Verify
(
_
=>
_
.
SetPop
(
"prefix:key"
,
CommandFlags
.
HighPriority
));
}
[
Fact
]
public
void
SetPop_2
()
{
wrapper
.
SetPop
(
"key"
,
5
,
CommandFlags
.
HighPriority
);
mock
.
Verify
(
_
=>
_
.
SetPop
(
"prefix:key"
,
5
,
CommandFlags
.
HighPriority
));
}
[
Fact
]
public
void
SetRandomMember
()
{
...
...
StackExchange.Redis.Tests/WrapperBaseTests.cs
View file @
80dd68f6
...
...
@@ -535,12 +535,19 @@ public void SetMoveAsync()
}
[
Fact
]
public
void
SetPopAsync
()
public
void
SetPopAsync
_1
()
{
wrapper
.
SetPopAsync
(
"key"
,
CommandFlags
.
HighPriority
);
mock
.
Verify
(
_
=>
_
.
SetPopAsync
(
"prefix:key"
,
CommandFlags
.
HighPriority
));
}
[
Fact
]
public
void
SetPopAsync_2
()
{
wrapper
.
SetPopAsync
(
"key"
,
5
,
CommandFlags
.
HighPriority
);
mock
.
Verify
(
_
=>
_
.
SetPopAsync
(
"prefix:key"
,
5
,
CommandFlags
.
HighPriority
));
}
[
Fact
]
public
void
SetRandomMemberAsync
()
{
...
...
StackExchange.Redis/StackExchange/Redis/Interfaces/IDatabase.cs
View file @
80dd68f6
...
...
@@ -962,6 +962,16 @@ public interface IDatabase : IRedis, IDatabaseAsync
/// <remarks>https://redis.io/commands/spop</remarks>
RedisValue
SetPop
(
RedisKey
key
,
CommandFlags
flags
=
CommandFlags
.
None
);
/// <summary>
/// Removes and returns an array of count random elements from the set value stored at key.
/// </summary>
/// <param name="key">The key of the set.</param>
/// <param name="count">The count of members to get.</param>
/// <param name="flags">The flags to use for this operation.</param>
/// <returns>An array of elements, or an empty array when key does not exist.</returns>
/// <remarks>https://redis.io/commands/spop</remarks>
RedisValue
[]
SetPop
(
RedisKey
key
,
long
count
,
CommandFlags
flags
=
CommandFlags
.
None
);
/// <summary>
/// Return a random element from the set value stored at key.
/// </summary>
...
...
StackExchange.Redis/StackExchange/Redis/Interfaces/IDatabaseAsync.cs
View file @
80dd68f6
...
...
@@ -925,6 +925,16 @@ public interface IDatabaseAsync : IRedisAsync
/// <remarks>https://redis.io/commands/spop</remarks>
Task
<
RedisValue
>
SetPopAsync
(
RedisKey
key
,
CommandFlags
flags
=
CommandFlags
.
None
);
/// <summary>
/// Removes and returns an array of count random elements from the set value stored at key.
/// </summary>
/// <param name="key">The key of the set.</param>
/// <param name="count">The count of members to get.</param>
/// <param name="flags">The flags to use for this operation.</param>
/// <returns>An array of elements, or an empty array when key does not exist.</returns>
/// <remarks>https://redis.io/commands/spop</remarks>
Task
<
RedisValue
[
]>
SetPopAsync
(
RedisKey
key
,
long
count
,
CommandFlags
flags
=
CommandFlags
.
None
);
/// <summary>
/// Return a random element from the set value stored at key.
/// </summary>
...
...
StackExchange.Redis/StackExchange/Redis/KeyspaceIsolation/DatabaseWrapper.cs
View file @
80dd68f6
...
...
@@ -447,6 +447,11 @@ public RedisValue SetPop(RedisKey key, CommandFlags flags = CommandFlags.None)
return
Inner
.
SetPop
(
ToInner
(
key
),
flags
);
}
public
RedisValue
[]
SetPop
(
RedisKey
key
,
long
count
,
CommandFlags
flags
=
CommandFlags
.
None
)
{
return
Inner
.
SetPop
(
ToInner
(
key
),
count
,
flags
);
}
public
RedisValue
SetRandomMember
(
RedisKey
key
,
CommandFlags
flags
=
CommandFlags
.
None
)
{
return
Inner
.
SetRandomMember
(
ToInner
(
key
),
flags
);
...
...
StackExchange.Redis/StackExchange/Redis/KeyspaceIsolation/WrapperBase.cs
View file @
80dd68f6
...
...
@@ -426,6 +426,11 @@ public Task<RedisValue> SetPopAsync(RedisKey key, CommandFlags flags = CommandFl
return
Inner
.
SetPopAsync
(
ToInner
(
key
),
flags
);
}
public
Task
<
RedisValue
[
]>
SetPopAsync
(
RedisKey
key
,
long
count
,
CommandFlags
flags
=
CommandFlags
.
None
)
{
return
Inner
.
SetPopAsync
(
ToInner
(
key
),
count
,
flags
);
}
public
Task
<
RedisValue
>
SetRandomMemberAsync
(
RedisKey
key
,
CommandFlags
flags
=
CommandFlags
.
None
)
{
return
Inner
.
SetRandomMemberAsync
(
ToInner
(
key
),
flags
);
...
...
StackExchange.Redis/StackExchange/Redis/RedisDatabase.cs
View file @
80dd68f6
...
...
@@ -1245,12 +1245,24 @@ public RedisValue SetPop(RedisKey key, CommandFlags flags = CommandFlags.None)
return
ExecuteSync
(
msg
,
ResultProcessor
.
RedisValue
);
}
public
RedisValue
[]
SetPop
(
RedisKey
key
,
long
count
,
CommandFlags
flags
=
CommandFlags
.
None
)
{
var
msg
=
Message
.
Create
(
Database
,
flags
,
RedisCommand
.
SPOP
,
key
,
count
);
return
ExecuteSync
(
msg
,
ResultProcessor
.
RedisValueArray
);
}
public
Task
<
RedisValue
>
SetPopAsync
(
RedisKey
key
,
CommandFlags
flags
=
CommandFlags
.
None
)
{
var
msg
=
Message
.
Create
(
Database
,
flags
,
RedisCommand
.
SPOP
,
key
);
return
ExecuteAsync
(
msg
,
ResultProcessor
.
RedisValue
);
}
public
Task
<
RedisValue
[
]>
SetPopAsync
(
RedisKey
key
,
long
count
,
CommandFlags
flags
=
CommandFlags
.
None
)
{
var
msg
=
Message
.
Create
(
Database
,
flags
,
RedisCommand
.
SPOP
,
key
,
count
);
return
ExecuteAsync
(
msg
,
ResultProcessor
.
RedisValueArray
);
}
public
RedisValue
SetRandomMember
(
RedisKey
key
,
CommandFlags
flags
=
CommandFlags
.
None
)
{
var
msg
=
Message
.
Create
(
Database
,
flags
,
RedisCommand
.
SRANDMEMBER
,
key
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment