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

Commit b67c772

Browse files
committed
clean up
1 parent 0c39476 commit b67c772

File tree

2 files changed

+38
-81
lines changed

2 files changed

+38
-81
lines changed

src/ServiceStack.Redis/BasicRedisClientManager.Async.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ ValueTask IAsyncDisposable.DisposeAsync()
5757
async Task<T> ICacheClientAsync.GetAsync<T>(string key, CancellationToken token)
5858
{
5959
await using var client = await GetReadOnlyCacheClientAsync(token).ConfigureAwait(false);
60-
return await client.GetAsync<T>(key).ConfigureAwait(false);
60+
return await client.GetAsync<T>(key, token).ConfigureAwait(false);
6161
}
6262

6363
async Task<bool> ICacheClientAsync.SetAsync<T>(string key, T value, CancellationToken token)

src/ServiceStack.Redis/BasicRedisClientManager.ICacheClient.cs

+37-80
Original file line numberDiff line numberDiff line change
@@ -30,152 +30,109 @@ namespace ServiceStack.Redis
3030
public partial class BasicRedisClientManager
3131
: ICacheClient
3232
{
33-
public ICacheClient GetCacheClient()
34-
{
35-
return new RedisClientManagerCacheClient(this);
36-
}
33+
public ICacheClient GetCacheClient() =>
34+
new RedisClientManagerCacheClient(this);
3735

38-
public ICacheClient GetReadOnlyCacheClient()
39-
{
40-
return ConfigureRedisClient(this.GetReadOnlyClientImpl());
41-
}
36+
public ICacheClient GetReadOnlyCacheClient() =>
37+
ConfigureRedisClient(this.GetReadOnlyClientImpl());
4238

43-
private ICacheClient ConfigureRedisClient(IRedisClient client)
44-
{
45-
return client;
46-
}
47-
48-
#region Implementation of ICacheClient
39+
private ICacheClient ConfigureRedisClient(IRedisClient client) => client;
4940

5041
public bool Remove(string key)
5142
{
52-
using (var client = GetReadOnlyCacheClient())
53-
{
54-
return client.Remove(key);
55-
}
43+
using var client = GetReadOnlyCacheClient();
44+
return client.Remove(key);
5645
}
5746

5847
public void RemoveAll(IEnumerable<string> keys)
5948
{
60-
using (var client = GetCacheClient())
61-
{
62-
client.RemoveAll(keys);
63-
}
49+
using var client = GetCacheClient();
50+
client.RemoveAll(keys);
6451
}
6552

6653
public T Get<T>(string key)
6754
{
68-
using (var client = GetReadOnlyCacheClient())
69-
{
70-
return client.Get<T>(key);
71-
}
55+
using var client = GetReadOnlyCacheClient();
56+
return client.Get<T>(key);
7257
}
7358

7459
public long Increment(string key, uint amount)
7560
{
76-
using (var client = GetCacheClient())
77-
{
78-
return client.Increment(key, amount);
79-
}
61+
using var client = GetCacheClient();
62+
return client.Increment(key, amount);
8063
}
8164

8265
public long Decrement(string key, uint amount)
8366
{
84-
using (var client = GetCacheClient())
85-
{
86-
return client.Decrement(key, amount);
87-
}
67+
using var client = GetCacheClient();
68+
return client.Decrement(key, amount);
8869
}
8970

9071
public bool Add<T>(string key, T value)
9172
{
92-
using (var client = GetCacheClient())
93-
{
94-
return client.Add(key, value);
95-
}
73+
using var client = GetCacheClient();
74+
return client.Add(key, value);
9675
}
9776

9877
public bool Set<T>(string key, T value)
9978
{
100-
using (var client = GetCacheClient())
101-
{
102-
return client.Set(key, value);
103-
}
79+
using var client = GetCacheClient();
80+
return client.Set(key, value);
10481
}
10582

10683
public bool Replace<T>(string key, T value)
10784
{
108-
using (var client = GetCacheClient())
109-
{
110-
return client.Replace(key, value);
111-
}
85+
using var client = GetCacheClient();
86+
return client.Replace(key, value);
11287
}
11388

11489
public bool Add<T>(string key, T value, DateTime expiresAt)
11590
{
116-
using (var client = GetCacheClient())
117-
{
118-
return client.Add(key, value, expiresAt);
119-
}
91+
using var client = GetCacheClient();
92+
return client.Add(key, value, expiresAt);
12093
}
12194

12295
public bool Set<T>(string key, T value, DateTime expiresAt)
12396
{
124-
using (var client = GetCacheClient())
125-
{
126-
return client.Set(key, value, expiresAt);
127-
}
97+
using var client = GetCacheClient();
98+
return client.Set(key, value, expiresAt);
12899
}
129100

130101
public bool Replace<T>(string key, T value, DateTime expiresAt)
131102
{
132-
using (var client = GetCacheClient())
133-
{
134-
return client.Replace(key, value, expiresAt);
135-
}
103+
using var client = GetCacheClient();
104+
return client.Replace(key, value, expiresAt);
136105
}
137106

138107
public bool Add<T>(string key, T value, TimeSpan expiresIn)
139108
{
140-
using (var client = GetCacheClient())
141-
{
142-
return client.Add(key, value, expiresIn);
143-
}
109+
using var client = GetCacheClient();
110+
return client.Add(key, value, expiresIn);
144111
}
145112

146113
public bool Set<T>(string key, T value, TimeSpan expiresIn)
147114
{
148-
using (var client = GetCacheClient())
149-
{
150-
return client.Set(key, value, expiresIn);
151-
}
115+
using var client = GetCacheClient();
116+
return client.Set(key, value, expiresIn);
152117
}
153118

154119
public bool Replace<T>(string key, T value, TimeSpan expiresIn)
155120
{
156-
using (var client = GetCacheClient())
157-
{
158-
return client.Replace(key, value, expiresIn);
159-
}
121+
using var client = GetCacheClient();
122+
return client.Replace(key, value, expiresIn);
160123
}
161124

162125
public void FlushAll()
163126
{
164-
using (var client = GetCacheClient())
165-
{
166-
client.FlushAll();
167-
}
127+
using var client = GetCacheClient();
128+
client.FlushAll();
168129
}
169130

170131
public IDictionary<string, T> GetAll<T>(IEnumerable<string> keys)
171132
{
172-
using (var client = GetReadOnlyCacheClient())
173-
{
174-
return client.GetAll<T>(keys);
175-
}
133+
using var client = GetReadOnlyCacheClient();
134+
return client.GetAll<T>(keys);
176135
}
177-
178-
#endregion
179136
}
180137

181138

0 commit comments

Comments
 (0)