2
2
using System . Collections ;
3
3
using System . Linq ;
4
4
using System . Collections . Generic ;
5
- using ServiceStack . Configuration ;
6
- using ServiceStack . Templates ;
5
+ using ServiceStack . Script ;
7
6
8
7
namespace ServiceStack . Redis
9
8
{
@@ -21,7 +20,10 @@ public class RedisSearchResult
21
20
public long Size { get ; set ; }
22
21
}
23
22
24
- public class TemplateRedisFilters : TemplateFilter
23
+ [ Obsolete ( "Use RedisScripts" ) ]
24
+ public class TemplateRedisFilters : RedisScripts { }
25
+
26
+ public class RedisScripts : ScriptMethods
25
27
{
26
28
private IRedisClientsManager redisManager ;
27
29
public IRedisClientsManager RedisManager
@@ -30,7 +32,7 @@ public IRedisClientsManager RedisManager
30
32
set => redisManager = value ;
31
33
}
32
34
33
- T exec < T > ( Func < IRedisClient , T > fn , TemplateScopeContext scope , object options )
35
+ T exec < T > ( Func < IRedisClient , T > fn , ScriptScopeContext scope , object options )
34
36
{
35
37
try
36
38
{
@@ -94,8 +96,8 @@ object toObject(RedisText r)
94
96
return r . Text ;
95
97
}
96
98
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 )
99
101
{
100
102
if ( redisCommand == null )
101
103
return null ;
@@ -126,8 +128,8 @@ public object redisCall(TemplateScopeContext scope, object redisCommand, object
126
128
return result ;
127
129
}
128
130
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 )
131
133
{
132
134
var json = redisSearchKeysAsJson ( scope , query , options ) ;
133
135
const string noResult = "{\" cursor\" :0,\" results\" :{}}" ;
@@ -138,20 +140,20 @@ public List<RedisSearchResult> redisSearchKeys(TemplateScopeContext scope, strin
138
140
return searchResults . Results ;
139
141
}
140
142
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 ) ;
143
145
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 ) ;
145
147
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 >
147
149
{
148
150
{ "host" , r . Host } ,
149
151
{ "port" , r . Port } ,
150
152
{ "db" , r . Db } ,
151
153
} , scope , null ) ;
152
154
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 )
155
157
{
156
158
var connectionString = connectionInfo as string ;
157
159
if ( connectionString != null )
@@ -172,8 +174,8 @@ public string redisToConnectionString(TemplateScopeContext scope, object connect
172
174
return connectionString ;
173
175
}
174
176
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 )
177
179
{
178
180
try
179
181
{
@@ -196,7 +198,7 @@ public string redisChangeConnection(TemplateScopeContext scope, object newConnec
196
198
}
197
199
}
198
200
199
- public string redisSearchKeysAsJson ( TemplateScopeContext scope , string query , object options )
201
+ public string redisSearchKeysAsJson ( ScriptScopeContext scope , string query , object options )
200
202
{
201
203
if ( string . IsNullOrEmpty ( query ) )
202
204
return null ;
0 commit comments