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
78a5239b
Commit
78a5239b
authored
Mar 11, 2018
by
Nick Craver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup: RedisBase
parent
c3f1f2e9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
43 deletions
+22
-43
RedisBase.cs
StackExchange.Redis/StackExchange/Redis/RedisBase.cs
+22
-43
No files found.
StackExchange.Redis/StackExchange/Redis/RedisBase.cs
View file @
78a5239b
...
...
@@ -42,30 +42,15 @@ public Task QuitAsync(CommandFlags flags = CommandFlags.None)
return
ExecuteAsync
(
msg
,
ResultProcessor
.
DemandOK
);
}
public
override
string
ToString
()
{
return
multiplexer
.
ToString
();
}
public
override
string
ToString
()
=>
multiplexer
.
ToString
();
public
bool
TryWait
(
Task
task
)
{
return
task
.
Wait
(
multiplexer
.
TimeoutMilliseconds
);
}
public
bool
TryWait
(
Task
task
)
=>
task
.
Wait
(
multiplexer
.
TimeoutMilliseconds
);
public
void
Wait
(
Task
task
)
{
multiplexer
.
Wait
(
task
);
}
public
void
Wait
(
Task
task
)
=>
multiplexer
.
Wait
(
task
);
public
T
Wait
<
T
>(
Task
<
T
>
task
)
{
return
multiplexer
.
Wait
(
task
);
}
public
T
Wait
<
T
>(
Task
<
T
>
task
)
=>
multiplexer
.
Wait
(
task
);
public
void
WaitAll
(
params
Task
[]
tasks
)
{
multiplexer
.
WaitAll
(
tasks
);
}
public
void
WaitAll
(
params
Task
[]
tasks
)
=>
multiplexer
.
WaitAll
(
tasks
);
internal
virtual
Task
<
T
>
ExecuteAsync
<
T
>(
Message
message
,
ResultProcessor
<
T
>
processor
,
ServerEndPoint
server
=
null
)
{
...
...
@@ -140,7 +125,6 @@ private ResultProcessor.TimingProcessor.TimerMessage GetTimerMessage(CommandFlag
return
ResultProcessor
.
TimingProcessor
.
CreateMessage
(
0
,
flags
,
RedisCommand
.
EXISTS
,
(
RedisValue
)
multiplexer
.
UniqueId
);
}
internal
static
class
CursorUtils
{
internal
const
int
Origin
=
0
,
DefaultPageSize
=
10
;
...
...
@@ -152,6 +136,7 @@ internal static bool IsNil(RedisValue pattern)
return
rawValue
.
Length
==
1
&&
rawValue
[
0
]
==
'*'
;
}
}
internal
abstract
class
CursorEnumerable
<
T
>
:
IEnumerable
<
T
>,
IScanningCursor
{
private
readonly
RedisBase
redis
;
...
...
@@ -174,14 +159,10 @@ protected CursorEnumerable(RedisBase redis, ServerEndPoint server, int db, int p
initialOffset
=
pageOffset
;
}
public
IEnumerator
<
T
>
GetEnumerator
()
{
return
new
CursorEnumerator
(
this
);
}
System
.
Collections
.
IEnumerator
System
.
Collections
.
IEnumerable
.
GetEnumerator
()
{
return
GetEnumerator
();
}
public
IEnumerator
<
T
>
GetEnumerator
()
=>
new
CursorEnumerator
(
this
);
System
.
Collections
.
IEnumerator
System
.
Collections
.
IEnumerable
.
GetEnumerator
()
=>
GetEnumerator
();
internal
struct
ScanResult
{
public
readonly
long
Cursor
;
...
...
@@ -195,7 +176,6 @@ public ScanResult(long cursor, T[] values)
protected
abstract
Message
CreateMessage
(
long
cursor
);
protected
abstract
ResultProcessor
<
ScanResult
>
Processor
{
get
;
}
protected
ScanResult
GetNextPageSync
(
IScanningCursor
obj
,
long
cursor
)
...
...
@@ -203,25 +183,24 @@ protected ScanResult GetNextPageSync(IScanningCursor obj, long cursor)
activeCursor
=
obj
;
return
redis
.
ExecuteSync
(
CreateMessage
(
cursor
),
Processor
,
server
);
}
protected
Task
<
ScanResult
>
GetNextPageAsync
(
IScanningCursor
obj
,
long
cursor
)
{
activeCursor
=
obj
;
return
redis
.
ExecuteAsync
(
CreateMessage
(
cursor
),
Processor
,
server
);
}
protected
ScanResult
Wait
(
Task
<
ScanResult
>
pending
)
{
return
redis
.
Wait
(
pending
);
}
class
CursorEnumerator
:
IEnumerator
<
T
>,
IScanningCursor
protected
ScanResult
Wait
(
Task
<
ScanResult
>
pending
)
=>
redis
.
Wait
(
pending
);
private
class
CursorEnumerator
:
IEnumerator
<
T
>,
IScanningCursor
{
private
CursorEnumerable
<
T
>
parent
;
public
CursorEnumerator
(
CursorEnumerable
<
T
>
parent
)
{
if
(
parent
==
null
)
throw
new
ArgumentNullException
(
nameof
(
parent
));
this
.
parent
=
parent
;
this
.
parent
=
parent
??
throw
new
ArgumentNullException
(
nameof
(
parent
));
Reset
();
}
public
T
Current
=>
page
[
pageIndex
];
void
IDisposable
.
Dispose
()
{
parent
=
null
;
state
=
State
.
Disposed
;
}
...
...
@@ -245,9 +224,9 @@ private bool SimpleNext()
return
false
;
}
T
[]
page
;
Task
<
ScanResult
>
pending
;
int
pageIndex
;
private
T
[]
page
;
private
Task
<
ScanResult
>
pending
;
private
int
pageIndex
;
private
long
currentCursor
,
nextCursor
;
private
State
state
;
...
...
@@ -259,7 +238,7 @@ private enum State : byte
Disposed
,
}
void
ProcessReply
(
ScanResult
result
)
private
void
ProcessReply
(
ScanResult
result
)
{
currentCursor
=
nextCursor
;
nextCursor
=
result
.
Cursor
;
...
...
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