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
026476df
Unverified
Commit
026476df
authored
Feb 27, 2020
by
Marc Gravell
Committed by
GitHub
Feb 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API proposal for #1359 (#1361)
parent
fba49c53
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
1 deletion
+53
-1
StreamEntry.cs
src/StackExchange.Redis/StreamEntry.cs
+23
-1
Streams.cs
tests/StackExchange.Redis.Tests/Streams.cs
+30
-0
No files found.
src/StackExchange.Redis/StreamEntry.cs
View file @
026476df
namespace
StackExchange.Redis
using
System
;
namespace
StackExchange.Redis
{
/// <summary>
/// Describes an entry contained in a Redis Stream.
...
...
@@ -26,6 +28,26 @@ internal StreamEntry(RedisValue id, NameValueEntry[] values)
/// </summary>
public
NameValueEntry
[]
Values
{
get
;
}
/// <summary>
/// Search for a specific field by name, returning the value
/// </summary>
public
RedisValue
this
[
RedisValue
fieldName
]
{
get
{
var
values
=
Values
;
if
(
values
!=
null
)
{
for
(
int
i
=
0
;
i
<
values
.
Length
;
i
++)
{
if
(
values
[
i
].
name
==
fieldName
)
return
values
[
i
].
value
;
}
}
return
RedisValue
.
Null
;
}
}
/// <summary>
/// Indicates that the Redis Stream Entry is null.
/// </summary>
...
...
tests/StackExchange.Redis.Tests/Streams.cs
View file @
026476df
using
System
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
Newtonsoft.Json
;
using
Xunit
;
using
Xunit.Abstractions
;
...
...
@@ -1784,5 +1785,34 @@ public void StreamReadGroupMultiStreamWithNoAckShowsNoPendingMessages()
}
private
RedisKey
GetUniqueKey
(
string
type
)
=>
$"
{
type
}
_stream_
{
DateTimeOffset
.
UtcNow
.
ToUnixTimeMilliseconds
()}
"
;
[
Fact
]
public
async
Task
StreamReadIndexerUsage
()
{
var
streamName
=
GetUniqueKey
(
"read-group-indexer"
);
using
(
var
conn
=
Create
())
{
Skip
.
IfMissingFeature
(
conn
,
nameof
(
RedisFeatures
.
Streams
),
r
=>
r
.
Streams
);
var
db
=
conn
.
GetDatabase
();
await
db
.
StreamAddAsync
(
streamName
,
new
[]
{
new
NameValueEntry
(
"x"
,
"blah"
),
new
NameValueEntry
(
"msg"
,
@"{""name"":""test"",""id"":123}"
),
new
NameValueEntry
(
"y"
,
"more blah"
),
});
var
streamResult
=
await
db
.
StreamRangeAsync
(
streamName
,
count
:
1000
);
var
evntJson
=
streamResult
.
Select
(
x
=>
(
dynamic
)
JsonConvert
.
DeserializeObject
(
x
[
"msg"
]))
.
ToList
();
var
obj
=
Assert
.
Single
(
evntJson
);
Assert
.
Equal
(
123
,
(
int
)
obj
.
id
);
Assert
.
Equal
(
"test"
,
(
string
)
obj
.
name
);
}
}
}
}
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