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

Commit

Permalink
Rename to RedisScripts
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Feb 28, 2019
1 parent 17358b1 commit 56691b9
Showing 1 changed file with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
using System.Collections;
using System.Linq;
using System.Collections.Generic;
using ServiceStack.Configuration;
using ServiceStack.Templates;
using ServiceStack.Script;

namespace ServiceStack.Redis
{
Expand All @@ -21,7 +20,10 @@ public class RedisSearchResult
public long Size { get; set; }
}

public class TemplateRedisFilters : TemplateFilter
[Obsolete("Use RedisScripts")]
public class TemplateRedisFilters : RedisScripts {}

public class RedisScripts : ScriptMethods
{
private IRedisClientsManager redisManager;
public IRedisClientsManager RedisManager
Expand All @@ -30,7 +32,7 @@ public IRedisClientsManager RedisManager
set => redisManager = value;
}

T exec<T>(Func<IRedisClient, T> fn, TemplateScopeContext scope, object options)
T exec<T>(Func<IRedisClient, T> fn, ScriptScopeContext scope, object options)
{
try
{
Expand Down Expand Up @@ -94,8 +96,8 @@ object toObject(RedisText r)
return r.Text;
}

public object redisCall(TemplateScopeContext scope, object redisCommand) => redisCall(scope, redisCommand, null);
public object redisCall(TemplateScopeContext scope, object redisCommand, object options)
public object redisCall(ScriptScopeContext scope, object redisCommand) => redisCall(scope, redisCommand, null);
public object redisCall(ScriptScopeContext scope, object redisCommand, object options)
{
if (redisCommand == null)
return null;
Expand Down Expand Up @@ -126,8 +128,8 @@ public object redisCall(TemplateScopeContext scope, object redisCommand, object
return result;
}

public List<RedisSearchResult> redisSearchKeys(TemplateScopeContext scope, string query) => redisSearchKeys(scope, query, null);
public List<RedisSearchResult> redisSearchKeys(TemplateScopeContext scope, string query, object options)
public List<RedisSearchResult> redisSearchKeys(ScriptScopeContext scope, string query) => redisSearchKeys(scope, query, null);
public List<RedisSearchResult> redisSearchKeys(ScriptScopeContext scope, string query, object options)
{
var json = redisSearchKeysAsJson(scope, query, options);
const string noResult = "{\"cursor\":0,\"results\":{}}";
Expand All @@ -138,20 +140,20 @@ public List<RedisSearchResult> redisSearchKeys(TemplateScopeContext scope, strin
return searchResults.Results;
}

public Dictionary<string, string> redisInfo(TemplateScopeContext scope) => redisInfo(scope, null);
public Dictionary<string, string> redisInfo(TemplateScopeContext scope, object options) => exec(r => r.Info, scope, options);
public Dictionary<string, string> redisInfo(ScriptScopeContext scope) => redisInfo(scope, null);
public Dictionary<string, string> redisInfo(ScriptScopeContext scope, object options) => exec(r => r.Info, scope, options);

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

public Dictionary<string, object> redisConnection(TemplateScopeContext scope) => exec(r => new Dictionary<string, object>
public Dictionary<string, object> redisConnection(ScriptScopeContext scope) => exec(r => new Dictionary<string, object>
{
{ "host", r.Host },
{ "port", r.Port },
{ "db", r.Db },
}, scope, null);

public string redisToConnectionString(TemplateScopeContext scope, object connectionInfo) => redisToConnectionString(scope, connectionInfo, null);
public string redisToConnectionString(TemplateScopeContext scope, object connectionInfo, object options)
public string redisToConnectionString(ScriptScopeContext scope, object connectionInfo) => redisToConnectionString(scope, connectionInfo, null);
public string redisToConnectionString(ScriptScopeContext scope, object connectionInfo, object options)
{
var connectionString = connectionInfo as string;
if (connectionString != null)
Expand All @@ -172,8 +174,8 @@ public string redisToConnectionString(TemplateScopeContext scope, object connect
return connectionString;
}

public string redisChangeConnection(TemplateScopeContext scope, object newConnection) => redisChangeConnection(scope, newConnection, null);
public string redisChangeConnection(TemplateScopeContext scope, object newConnection, object options)
public string redisChangeConnection(ScriptScopeContext scope, object newConnection) => redisChangeConnection(scope, newConnection, null);
public string redisChangeConnection(ScriptScopeContext scope, object newConnection, object options)
{
try
{
Expand All @@ -196,7 +198,7 @@ public string redisChangeConnection(TemplateScopeContext scope, object newConnec
}
}

public string redisSearchKeysAsJson(TemplateScopeContext scope, string query, object options)
public string redisSearchKeysAsJson(ScriptScopeContext scope, string query, object options)
{
if (string.IsNullOrEmpty(query))
return null;
Expand Down

0 comments on commit 56691b9

Please sign in to comment.