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

Commit b9b8a0e

Browse files
authored
Async (#2)
Implement async APIs for ServiceStack.Redis
1 parent ed2145a commit b9b8a0e

File tree

179 files changed

+20986
-509
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

179 files changed

+20986
-509
lines changed

src/ServiceStack.Redis.sln

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.27130.2010
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29721.120
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{38F69F8F-9303-4BAF-B081-D28339163E07}"
77
ProjectSection(SolutionItems) = preProject
8+
..\build\build-core.proj = ..\build\build-core.proj
89
..\build\build.bat = ..\build\build.bat
910
..\build\build.proj = ..\build\build.proj
1011
..\build\build.tasks = ..\build\build.tasks
11-
..\README.md = ..\README.md
1212
Directory.Build.props = Directory.Build.props
13-
ServiceStack.Redis\ServiceStack.Redis.Core.csproj = ServiceStack.Redis\ServiceStack.Redis.Core.csproj
14-
..\build\build-core.proj = ..\build\build-core.proj
1513
..\tests\Directory.Build.props = ..\tests\Directory.Build.props
14+
..\README.md = ..\README.md
15+
ServiceStack.Redis\ServiceStack.Redis.Core.csproj = ServiceStack.Redis\ServiceStack.Redis.Core.csproj
1616
EndProjectSection
1717
EndProject
1818
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceStack.Redis", "ServiceStack.Redis\ServiceStack.Redis.csproj", "{AF99F19B-4C04-4F58-81EF-B092F1FCC540}"
@@ -23,6 +23,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Console.Tests", "..\tests\C
2323
EndProject
2424
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceStack.Redis.Tests.Sentinel", "..\tests\ServiceStack.Redis.Tests.Sentinel\ServiceStack.Redis.Tests.Sentinel.csproj", "{91C55091-A946-49B5-9517-8794EBCC5784}"
2525
EndProject
26+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStack.Redis.Benchmark", "..\tests\ServiceStack.Redis.Benchmark\ServiceStack.Redis.Benchmark.csproj", "{959CA5FE-6525-4EEF-86CA-F4978BEFF14F}"
27+
EndProject
2628
Global
2729
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2830
Debug|Any CPU = Debug|Any CPU
@@ -77,6 +79,18 @@ Global
7779
{91C55091-A946-49B5-9517-8794EBCC5784}.Release|x64.ActiveCfg = Release|Any CPU
7880
{91C55091-A946-49B5-9517-8794EBCC5784}.Release|x64.Build.0 = Release|Any CPU
7981
{91C55091-A946-49B5-9517-8794EBCC5784}.Release|x86.ActiveCfg = Release|Any CPU
82+
{959CA5FE-6525-4EEF-86CA-F4978BEFF14F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
83+
{959CA5FE-6525-4EEF-86CA-F4978BEFF14F}.Debug|Any CPU.Build.0 = Debug|Any CPU
84+
{959CA5FE-6525-4EEF-86CA-F4978BEFF14F}.Debug|x64.ActiveCfg = Debug|Any CPU
85+
{959CA5FE-6525-4EEF-86CA-F4978BEFF14F}.Debug|x64.Build.0 = Debug|Any CPU
86+
{959CA5FE-6525-4EEF-86CA-F4978BEFF14F}.Debug|x86.ActiveCfg = Debug|Any CPU
87+
{959CA5FE-6525-4EEF-86CA-F4978BEFF14F}.Debug|x86.Build.0 = Debug|Any CPU
88+
{959CA5FE-6525-4EEF-86CA-F4978BEFF14F}.Release|Any CPU.ActiveCfg = Release|Any CPU
89+
{959CA5FE-6525-4EEF-86CA-F4978BEFF14F}.Release|Any CPU.Build.0 = Release|Any CPU
90+
{959CA5FE-6525-4EEF-86CA-F4978BEFF14F}.Release|x64.ActiveCfg = Release|Any CPU
91+
{959CA5FE-6525-4EEF-86CA-F4978BEFF14F}.Release|x64.Build.0 = Release|Any CPU
92+
{959CA5FE-6525-4EEF-86CA-F4978BEFF14F}.Release|x86.ActiveCfg = Release|Any CPU
93+
{959CA5FE-6525-4EEF-86CA-F4978BEFF14F}.Release|x86.Build.0 = Release|Any CPU
8094
EndGlobalSection
8195
GlobalSection(SolutionProperties) = preSolution
8296
HideSolutionNode = FALSE

src/ServiceStack.Redis/AsyncInterfaces/IRedisClientAsync.cs

Lines changed: 395 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//
2+
// https://github.com/ServiceStack/ServiceStack.Redis
3+
// ServiceStack.Redis: ECMA CLI Binding to the Redis key-value storage system
4+
//
5+
// Authors:
6+
// Demis Bellot ([email protected])
7+
//
8+
// Copyright 2017 ServiceStack, Inc. All Rights Reserved.
9+
//
10+
// Licensed under the same terms of ServiceStack.
11+
//
12+
13+
using System;
14+
using System.Threading;
15+
using System.Threading.Tasks;
16+
using ServiceStack.Caching;
17+
18+
namespace ServiceStack.Redis
19+
{
20+
public interface IRedisClientsManagerAsync : IAsyncDisposable
21+
{
22+
/// <summary>
23+
/// Returns a Read/Write client (The default) using the hosts defined in ReadWriteHosts
24+
/// </summary>
25+
/// <returns></returns>
26+
ValueTask<IRedisClientAsync> GetClientAsync(CancellationToken cancellationToken = default);
27+
28+
/// <summary>
29+
/// Returns a ReadOnly client using the hosts defined in ReadOnlyHosts.
30+
/// </summary>
31+
/// <returns></returns>
32+
ValueTask<IRedisClientAsync> GetReadOnlyClientAsync(CancellationToken cancellationToken = default);
33+
34+
/// <summary>
35+
/// Returns a Read/Write ICacheClient (The default) using the hosts defined in ReadWriteHosts
36+
/// </summary>
37+
/// <returns></returns>
38+
ValueTask<ICacheClientAsync> GetCacheClientAsync(CancellationToken cancellationToken = default);
39+
40+
/// <summary>
41+
/// Returns a ReadOnly ICacheClient using the hosts defined in ReadOnlyHosts.
42+
/// </summary>
43+
/// <returns></returns>
44+
ValueTask<ICacheClientAsync> GetReadOnlyCacheClientAsync(CancellationToken cancellationToken = default);
45+
}
46+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//
2+
// https://github.com/ServiceStack/ServiceStack.Redis
3+
// ServiceStack.Redis: ECMA CLI Binding to the Redis key-value storage system
4+
//
5+
// Authors:
6+
// Demis Bellot ([email protected])
7+
//
8+
// Copyright 2017 ServiceStack, Inc. All Rights Reserved.
9+
//
10+
// Licensed under the same terms of ServiceStack.
11+
//
12+
13+
using System.Collections.Generic;
14+
using System.Threading;
15+
using System.Threading.Tasks;
16+
using ServiceStack.Model;
17+
18+
namespace ServiceStack.Redis.Generic
19+
{
20+
public interface IRedisHashAsync<TKey, TValue> : IAsyncEnumerable<KeyValuePair<TKey, TValue>>, IHasStringId
21+
{
22+
ValueTask<Dictionary<TKey, TValue>> GetAllAsync(CancellationToken cancellationToken = default);
23+
24+
ValueTask<int> CountAsync(CancellationToken cancellationToken = default);
25+
ValueTask AddAsync(KeyValuePair<TKey, TValue> item, CancellationToken cancellationToken = default);
26+
ValueTask AddAsync(TKey key, TValue value, CancellationToken cancellationToken = default);
27+
ValueTask ClearAsync(CancellationToken cancellationToken = default);
28+
ValueTask<bool> ContainsKeyAsync(TKey key, CancellationToken cancellationToken = default);
29+
ValueTask<bool> RemoveAsync(TKey key, CancellationToken cancellationToken = default);
30+
}
31+
32+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System.Collections.Generic;
2+
using System.Threading;
3+
using System.Threading.Tasks;
4+
using ServiceStack.Model;
5+
6+
namespace ServiceStack.Redis
7+
{
8+
public interface IRedisHashAsync
9+
: IAsyncEnumerable<KeyValuePair<string, string>>, IHasStringId
10+
{
11+
ValueTask<bool> AddIfNotExistsAsync(KeyValuePair<string, string> item, CancellationToken cancellationToken = default);
12+
ValueTask AddRangeAsync(IEnumerable<KeyValuePair<string, string>> items, CancellationToken cancellationToken = default);
13+
ValueTask<long> IncrementValueAsync(string key, int incrementBy, CancellationToken cancellationToken = default);
14+
15+
// shim the basic ICollection etc APIs
16+
ValueTask<int> CountAsync(CancellationToken cancellationToken = default);
17+
ValueTask AddAsync(KeyValuePair<string, string> item, CancellationToken cancellationToken = default);
18+
ValueTask AddAsync(string key, string value, CancellationToken cancellationToken = default);
19+
ValueTask ClearAsync(CancellationToken cancellationToken = default);
20+
ValueTask<bool> ContainsKeyAsync(string key, CancellationToken cancellationToken = default);
21+
ValueTask<bool> RemoveAsync(string key, CancellationToken cancellationToken = default);
22+
}
23+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
//
2+
// https://github.com/ServiceStack/ServiceStack.Redis
3+
// ServiceStack.Redis: ECMA CLI Binding to the Redis key-value storage system
4+
//
5+
// Authors:
6+
// Demis Bellot Async([email protected], CancellationToken cancellationToken = default)
7+
//
8+
// Copyright 2017 ServiceStack, Inc. All Rights Reserved.
9+
//
10+
// Licensed under the same terms of ServiceStack.
11+
//
12+
13+
using System;
14+
using System.Collections.Generic;
15+
using System.Threading;
16+
using System.Threading.Tasks;
17+
using ServiceStack.Model;
18+
19+
namespace ServiceStack.Redis.Generic
20+
{
21+
/// <summary>
22+
/// Wrap the common redis list operations under a IList[string] interface.
23+
/// </summary>
24+
25+
public interface IRedisListAsync<T>
26+
: IAsyncEnumerable<T>, IHasStringId
27+
{
28+
ValueTask<int> CountAsync(CancellationToken cancellationToken = default);
29+
ValueTask<List<T>> GetAllAsync(CancellationToken cancellationToken = default);
30+
ValueTask<List<T>> GetRangeAsync(int startingFrom, int endingAt, CancellationToken cancellationToken = default);
31+
ValueTask<List<T>> GetRangeFromSortedListAsync(int startingFrom, int endingAt, CancellationToken cancellationToken = default);
32+
ValueTask RemoveAllAsync(CancellationToken cancellationToken = default);
33+
ValueTask TrimAsync(int keepStartingFrom, int keepEndingAt, CancellationToken cancellationToken = default);
34+
ValueTask<long> RemoveValueAsync(T value, CancellationToken cancellationToken = default);
35+
ValueTask<long> RemoveValueAsync(T value, int noOfMatches, CancellationToken cancellationToken = default);
36+
37+
ValueTask AddRangeAsync(IEnumerable<T> values, CancellationToken cancellationToken = default);
38+
ValueTask AppendAsync(T value, CancellationToken cancellationToken = default);
39+
ValueTask PrependAsync(T value, CancellationToken cancellationToken = default);
40+
ValueTask<T> RemoveStartAsync(CancellationToken cancellationToken = default);
41+
ValueTask<T> BlockingRemoveStartAsync(TimeSpan? timeOut, CancellationToken cancellationToken = default);
42+
ValueTask<T> RemoveEndAsync(CancellationToken cancellationToken = default);
43+
44+
ValueTask EnqueueAsync(T value, CancellationToken cancellationToken = default);
45+
ValueTask<T> DequeueAsync(CancellationToken cancellationToken = default);
46+
ValueTask<T> BlockingDequeueAsync(TimeSpan? timeOut, CancellationToken cancellationToken = default);
47+
48+
ValueTask PushAsync(T value, CancellationToken cancellationToken = default);
49+
ValueTask<T> PopAsync(CancellationToken cancellationToken = default);
50+
ValueTask<T> BlockingPopAsync(TimeSpan? timeOut, CancellationToken cancellationToken = default);
51+
ValueTask<T> PopAndPushAsync(IRedisListAsync<T> toList, CancellationToken cancellationToken = default);
52+
53+
54+
ValueTask<bool> RemoveAsync(T item, CancellationToken cancellationToken = default);
55+
ValueTask AddAsync(T item, CancellationToken cancellationToken = default);
56+
ValueTask RemoveAtAsync(int index, CancellationToken cancellationToken = default);
57+
ValueTask<bool> ContainsAsync(T item, CancellationToken cancellationToken = default);
58+
ValueTask ClearAsync(CancellationToken cancellationToken = default);
59+
ValueTask<int> IndexOfAsync(T item, CancellationToken cancellationToken = default);
60+
61+
ValueTask<T> ElementAtAsync(int index, CancellationToken cancellationToken = default);
62+
ValueTask SetValueAsync(int index, T value, CancellationToken cancellationToken = default);
63+
}
64+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
//
2+
// https://github.com/ServiceStack/ServiceStack.Redis
3+
// ServiceStack.Redis: ECMA CLI Binding to the Redis key-value storage system
4+
//
5+
// Authors:
6+
// Demis Bellot Async([email protected])
7+
//
8+
// Copyright 2017 ServiceStack, Inc. All Rights Reserved.
9+
//
10+
// Licensed under the same terms of ServiceStack.
11+
//
12+
13+
using System;
14+
using System.Collections.Generic;
15+
using System.Threading;
16+
using System.Threading.Tasks;
17+
using ServiceStack.Model;
18+
19+
namespace ServiceStack.Redis
20+
{
21+
public interface IRedisListAsync
22+
: IAsyncEnumerable<string>, IHasStringId
23+
{
24+
ValueTask<int> CountAsync(CancellationToken cancellationToken = default);
25+
ValueTask<List<string>> GetAllAsync(CancellationToken cancellationToken = default);
26+
ValueTask<List<string>> GetRangeAsync(int startingFrom, int endingAt, CancellationToken cancellationToken = default);
27+
ValueTask<List<string>> GetRangeFromSortedListAsync(int startingFrom, int endingAt, CancellationToken cancellationToken = default);
28+
ValueTask RemoveAllAsync(CancellationToken cancellationToken = default);
29+
ValueTask TrimAsync(int keepStartingFrom, int keepEndingAt, CancellationToken cancellationToken = default);
30+
ValueTask<long> RemoveValueAsync(string value, CancellationToken cancellationToken = default);
31+
ValueTask<long> RemoveValueAsync(string value, int noOfMatches, CancellationToken cancellationToken = default);
32+
33+
ValueTask PrependAsync(string value, CancellationToken cancellationToken = default);
34+
ValueTask AppendAsync(string value, CancellationToken cancellationToken = default);
35+
ValueTask<string> RemoveStartAsync(CancellationToken cancellationToken = default);
36+
ValueTask<string> BlockingRemoveStartAsync(TimeSpan? timeOut, CancellationToken cancellationToken = default);
37+
ValueTask<string> RemoveEndAsync(CancellationToken cancellationToken = default);
38+
39+
ValueTask EnqueueAsync(string value, CancellationToken cancellationToken = default);
40+
ValueTask<string> DequeueAsync(CancellationToken cancellationToken = default);
41+
ValueTask<string> BlockingDequeueAsync(TimeSpan? timeOut, CancellationToken cancellationToken = default);
42+
43+
ValueTask PushAsync(string value, CancellationToken cancellationToken = default);
44+
ValueTask<string> PopAsync(CancellationToken cancellationToken = default);
45+
ValueTask<string> BlockingPopAsync(TimeSpan? timeOut, CancellationToken cancellationToken = default);
46+
ValueTask<string> PopAndPushAsync(IRedisListAsync toList, CancellationToken cancellationToken = default);
47+
48+
ValueTask<bool> RemoveAsync(string item, CancellationToken cancellationToken = default);
49+
ValueTask AddAsync(string item, CancellationToken cancellationToken = default);
50+
ValueTask RemoveAtAsync(int index, CancellationToken cancellationToken = default);
51+
ValueTask<bool> ContainsAsync(string item, CancellationToken cancellationToken = default);
52+
ValueTask ClearAsync(CancellationToken cancellationToken = default);
53+
ValueTask<int> IndexOfAsync(string item, CancellationToken cancellationToken = default);
54+
55+
ValueTask<string> ElementAtAsync(int index, CancellationToken cancellationToken = default);
56+
ValueTask SetValueAsync(int index, string value, CancellationToken cancellationToken = default);
57+
}
58+
}

0 commit comments

Comments
 (0)