Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 0e4a641

Browse files
committed
Remove scan specialization
1 parent c997f7b commit 0e4a641

File tree

4 files changed

+41
-84
lines changed

4 files changed

+41
-84
lines changed

lib/ServiceStack.Interfaces.dll

512 Bytes
Binary file not shown.

src/ServiceStack.Redis/RedisClient.cs

Lines changed: 40 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,101 +1023,73 @@ public void RemoveByRegex(string pattern)
10231023

10241024
public IEnumerable<string> ScanAllKeys(string pattern = null, int pageSize = 1000)
10251025
{
1026-
try
1026+
var ret = new ScanResult();
1027+
while (true)
10271028
{
1028-
var ret = CreateScanResult();
1029-
while (true)
1030-
{
1031-
ret = pattern != null
1032-
? base.Scan(ret.Cursor, pageSize, match: pattern)
1033-
: base.Scan(ret.Cursor, pageSize);
1029+
ret = pattern != null
1030+
? base.Scan(ret.Cursor, pageSize, match: pattern)
1031+
: base.Scan(ret.Cursor, pageSize);
10341032

1035-
foreach (var key in ret.Results)
1036-
{
1037-
yield return key.FromUtf8Bytes();
1038-
}
1039-
1040-
if (ret.Cursor == 0) break;
1033+
foreach (var key in ret.Results)
1034+
{
1035+
yield return key.FromUtf8Bytes();
10411036
}
1042-
}
1043-
finally
1044-
{
1045-
EndScanResult();
1037+
1038+
if (ret.Cursor == 0) break;
10461039
}
10471040
}
10481041

10491042
public IEnumerable<string> ScanAllSetItems(string setId, string pattern = null, int pageSize = 1000)
10501043
{
1051-
try
1044+
var ret = new ScanResult();
1045+
while (true)
10521046
{
1053-
var ret = CreateScanResult();
1054-
while (true)
1055-
{
1056-
ret = pattern != null
1057-
? base.SScan(setId, ret.Cursor, pageSize, match: pattern)
1058-
: base.SScan(setId, ret.Cursor, pageSize);
1047+
ret = pattern != null
1048+
? base.SScan(setId, ret.Cursor, pageSize, match: pattern)
1049+
: base.SScan(setId, ret.Cursor, pageSize);
10591050

1060-
foreach (var key in ret.Results)
1061-
{
1062-
yield return key.FromUtf8Bytes();
1063-
}
1064-
1065-
if (ret.Cursor == 0) break;
1051+
foreach (var key in ret.Results)
1052+
{
1053+
yield return key.FromUtf8Bytes();
10661054
}
1067-
}
1068-
finally
1069-
{
1070-
EndScanResult();
1055+
1056+
if (ret.Cursor == 0) break;
10711057
}
10721058
}
10731059

10741060
public IEnumerable<KeyValuePair<string, double>> ScanAllSortedSetItems(string setId, string pattern = null, int pageSize = 1000)
10751061
{
1076-
try
1062+
var ret = new ScanResult();
1063+
while (true)
10771064
{
1078-
var ret = CreateScanResult();
1079-
while (true)
1080-
{
1081-
ret = pattern != null
1082-
? base.ZScan(setId, ret.Cursor, pageSize, match: pattern)
1083-
: base.ZScan(setId, ret.Cursor, pageSize);
1065+
ret = pattern != null
1066+
? base.ZScan(setId, ret.Cursor, pageSize, match: pattern)
1067+
: base.ZScan(setId, ret.Cursor, pageSize);
10841068

1085-
foreach (var entry in ret.AsItemsWithScores())
1086-
{
1087-
yield return entry;
1088-
}
1089-
1090-
if (ret.Cursor == 0) break;
1069+
foreach (var entry in ret.AsItemsWithScores())
1070+
{
1071+
yield return entry;
10911072
}
1092-
}
1093-
finally
1094-
{
1095-
EndScanResult();
1073+
1074+
if (ret.Cursor == 0) break;
10961075
}
10971076
}
10981077

10991078
public IEnumerable<KeyValuePair<string, string>> ScanAllHashEntries(string hashId, string pattern = null, int pageSize = 1000)
11001079
{
1101-
try
1080+
var ret = new ScanResult();
1081+
while (true)
11021082
{
1103-
var ret = CreateScanResult();
1104-
while (true)
1105-
{
1106-
ret = pattern != null
1107-
? base.HScan(hashId, ret.Cursor, pageSize, match: pattern)
1108-
: base.HScan(hashId, ret.Cursor, pageSize);
1083+
ret = pattern != null
1084+
? base.HScan(hashId, ret.Cursor, pageSize, match: pattern)
1085+
: base.HScan(hashId, ret.Cursor, pageSize);
11091086

1110-
foreach (var entry in ret.AsKeyValues())
1111-
{
1112-
yield return entry;
1113-
}
1114-
1115-
if (ret.Cursor == 0) break;
1087+
foreach (var entry in ret.AsKeyValues())
1088+
{
1089+
yield return entry;
11161090
}
1117-
}
1118-
finally
1119-
{
1120-
EndScanResult();
1091+
1092+
if (ret.Cursor == 0) break;
11211093
}
11221094
}
11231095

src/ServiceStack.Redis/RedisNativeClient.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,6 @@ internal IRedisPipelineShared Pipeline
147147
}
148148
}
149149

150-
private bool IsScan;
151-
152150
internal void EndPipeline()
153151
{
154152
ResetSendBuffer();
@@ -2139,19 +2137,6 @@ public RedisPipelineCommand CreatePipelineCommand()
21392137
return new RedisPipelineCommand(this);
21402138
}
21412139

2142-
protected ScanResult CreateScanResult()
2143-
{
2144-
IsScan = true;
2145-
return new ScanResult();
2146-
}
2147-
2148-
protected void EndScanResult()
2149-
{
2150-
IsScan = false;
2151-
Interlocked.Increment(ref __requestsPerHour);
2152-
}
2153-
2154-
21552140
#endregion
21562141

21572142
internal bool IsDisposed { get; set; }

src/ServiceStack.Redis/RedisNativeClient_Utils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ private static byte[] GetCmdBytes(char cmdPrefix, int noOfLines)
351351
/// <returns></returns>
352352
protected void WriteCommandToSendBuffer(params byte[][] cmdWithBinaryArgs)
353353
{
354-
if (Pipeline == null && Transaction == null && !IsScan)
354+
if (Pipeline == null && Transaction == null)
355355
{
356356
Interlocked.Increment(ref __requestsPerHour);
357357
if (__requestsPerHour % 20 == 0)

0 commit comments

Comments
 (0)