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

Commit 56691b9

Browse files
committed
Rename to RedisScripts
1 parent 17358b1 commit 56691b9

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

src/ServiceStack.Redis/TemplateRedisFilters.cs renamed to src/ServiceStack.Redis/RedisScripts.cs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
using System.Collections;
33
using System.Linq;
44
using System.Collections.Generic;
5-
using ServiceStack.Configuration;
6-
using ServiceStack.Templates;
5+
using ServiceStack.Script;
76

87
namespace ServiceStack.Redis
98
{
@@ -21,7 +20,10 @@ public class RedisSearchResult
2120
public long Size { get; set; }
2221
}
2322

24-
public class TemplateRedisFilters : TemplateFilter
23+
[Obsolete("Use RedisScripts")]
24+
public class TemplateRedisFilters : RedisScripts {}
25+
26+
public class RedisScripts : ScriptMethods
2527
{
2628
private IRedisClientsManager redisManager;
2729
public IRedisClientsManager RedisManager
@@ -30,7 +32,7 @@ public IRedisClientsManager RedisManager
3032
set => redisManager = value;
3133
}
3234

33-
T exec<T>(Func<IRedisClient, T> fn, TemplateScopeContext scope, object options)
35+
T exec<T>(Func<IRedisClient, T> fn, ScriptScopeContext scope, object options)
3436
{
3537
try
3638
{
@@ -94,8 +96,8 @@ object toObject(RedisText r)
9496
return r.Text;
9597
}
9698

97-
public object redisCall(TemplateScopeContext scope, object redisCommand) => redisCall(scope, redisCommand, null);
98-
public object redisCall(TemplateScopeContext scope, object redisCommand, object options)
99+
public object redisCall(ScriptScopeContext scope, object redisCommand) => redisCall(scope, redisCommand, null);
100+
public object redisCall(ScriptScopeContext scope, object redisCommand, object options)
99101
{
100102
if (redisCommand == null)
101103
return null;
@@ -126,8 +128,8 @@ public object redisCall(TemplateScopeContext scope, object redisCommand, object
126128
return result;
127129
}
128130

129-
public List<RedisSearchResult> redisSearchKeys(TemplateScopeContext scope, string query) => redisSearchKeys(scope, query, null);
130-
public List<RedisSearchResult> redisSearchKeys(TemplateScopeContext scope, string query, object options)
131+
public List<RedisSearchResult> redisSearchKeys(ScriptScopeContext scope, string query) => redisSearchKeys(scope, query, null);
132+
public List<RedisSearchResult> redisSearchKeys(ScriptScopeContext scope, string query, object options)
131133
{
132134
var json = redisSearchKeysAsJson(scope, query, options);
133135
const string noResult = "{\"cursor\":0,\"results\":{}}";
@@ -138,20 +140,20 @@ public List<RedisSearchResult> redisSearchKeys(TemplateScopeContext scope, strin
138140
return searchResults.Results;
139141
}
140142

141-
public Dictionary<string, string> redisInfo(TemplateScopeContext scope) => redisInfo(scope, null);
142-
public Dictionary<string, string> redisInfo(TemplateScopeContext scope, object options) => exec(r => r.Info, scope, options);
143+
public Dictionary<string, string> redisInfo(ScriptScopeContext scope) => redisInfo(scope, null);
144+
public Dictionary<string, string> redisInfo(ScriptScopeContext scope, object options) => exec(r => r.Info, scope, options);
143145

144-
public string redisConnectionString(TemplateScopeContext scope) => exec(r => $"{r.Host}:{r.Port}?db={r.Db}", scope, null);
146+
public string redisConnectionString(ScriptScopeContext scope) => exec(r => $"{r.Host}:{r.Port}?db={r.Db}", scope, null);
145147

146-
public Dictionary<string, object> redisConnection(TemplateScopeContext scope) => exec(r => new Dictionary<string, object>
148+
public Dictionary<string, object> redisConnection(ScriptScopeContext scope) => exec(r => new Dictionary<string, object>
147149
{
148150
{ "host", r.Host },
149151
{ "port", r.Port },
150152
{ "db", r.Db },
151153
}, scope, null);
152154

153-
public string redisToConnectionString(TemplateScopeContext scope, object connectionInfo) => redisToConnectionString(scope, connectionInfo, null);
154-
public string redisToConnectionString(TemplateScopeContext scope, object connectionInfo, object options)
155+
public string redisToConnectionString(ScriptScopeContext scope, object connectionInfo) => redisToConnectionString(scope, connectionInfo, null);
156+
public string redisToConnectionString(ScriptScopeContext scope, object connectionInfo, object options)
155157
{
156158
var connectionString = connectionInfo as string;
157159
if (connectionString != null)
@@ -172,8 +174,8 @@ public string redisToConnectionString(TemplateScopeContext scope, object connect
172174
return connectionString;
173175
}
174176

175-
public string redisChangeConnection(TemplateScopeContext scope, object newConnection) => redisChangeConnection(scope, newConnection, null);
176-
public string redisChangeConnection(TemplateScopeContext scope, object newConnection, object options)
177+
public string redisChangeConnection(ScriptScopeContext scope, object newConnection) => redisChangeConnection(scope, newConnection, null);
178+
public string redisChangeConnection(ScriptScopeContext scope, object newConnection, object options)
177179
{
178180
try
179181
{
@@ -196,7 +198,7 @@ public string redisChangeConnection(TemplateScopeContext scope, object newConnec
196198
}
197199
}
198200

199-
public string redisSearchKeysAsJson(TemplateScopeContext scope, string query, object options)
201+
public string redisSearchKeysAsJson(ScriptScopeContext scope, string query, object options)
200202
{
201203
if (string.IsNullOrEmpty(query))
202204
return null;

0 commit comments

Comments
 (0)