Exemplo n.º 1
0
 public Task <long> GeoRadiusStoreAsync(string key, decimal longitude, decimal latitude, decimal radius, GeoUnit unit = GeoUnit.m,
                                        long?count      = null, Collation?collation = null,
                                        string storekey = null, string storedistkey = null)
 {
     if (string.IsNullOrWhiteSpace(storekey) && string.IsNullOrWhiteSpace(storedistkey))
     {
         throw new ArgumentNullException(nameof(storekey));
     }
     return(CallAsync("GEORADIUS"
                      .InputKey(key)
                      .Input(longitude, latitude, radius, unit)
                      .InputIf(count != null, "COUNT", count)
                      .InputIf(collation != null, collation)
                      .InputIf(!string.IsNullOrWhiteSpace(storekey), "STORE", storekey)
                      .InputIf(!string.IsNullOrWhiteSpace(storedistkey), "STOREDIST", storedistkey), rt => rt.ThrowOrValue <long>()));
 }
Exemplo n.º 2
0
 public long GeoRadiusByMemberStore(string key, string member, decimal radius, GeoUnit unit = GeoUnit.m,
                                    long?count      = null, Collation?collation = null,
                                    string storekey = null, string storedistkey = null)
 {
     if (string.IsNullOrWhiteSpace(storekey) && string.IsNullOrWhiteSpace(storedistkey))
     {
         throw new ArgumentNullException(nameof(storekey));
     }
     return(Call("GEORADIUSBYMEMBER"
                 .InputKey(key)
                 .Input(member, radius, unit)
                 .InputIf(count != null, "COUNT", count)
                 .InputIf(collation != null, collation)
                 .InputIf(!string.IsNullOrWhiteSpace(storekey), "STORE", storekey)
                 .InputIf(!string.IsNullOrWhiteSpace(storedistkey), "STOREDIST", storedistkey), rt => rt.ThrowOrValue <long>()));
 }
Exemplo n.º 3
0
 GeoRadiusResult[] GeoRadius(string cmd, string key, string member, decimal?longitude, decimal?latitude, decimal radius, GeoUnit unit = GeoUnit.m,
                             bool withdoord = false, bool withdist      = false, bool withhash = false,
                             long?count     = null, Collation?collation = null) => Call <object, GeoRadiusResult[]>(cmd
                                                                                                                    .Input(key)
                                                                                                                    .InputIf(!string.IsNullOrEmpty(member), member)
                                                                                                                    .InputIf(longitude != null && latitude != null, longitude, latitude)
                                                                                                                    .InputRaw(radius)
                                                                                                                    .InputRaw(unit)
                                                                                                                    .InputIf(withdoord, "WITHCOORD")
                                                                                                                    .InputIf(withdist, "WITHDIST")
                                                                                                                    .InputIf(withhash, "WITHHASH")
                                                                                                                    .InputIf(count != null, "COUNT", count)
                                                                                                                    .InputIf(collation != null, collation)
                                                                                                                    .FlagKey(key), rt => rt.NewValue(a =>
 {
     if (withdoord || withdist || withhash)
     {
         var objs = a as List <object>;
         return(objs.Select(x =>
         {
             var objs2 = x as List <object>;
             var grr = new GeoRadiusResult {
                 member = objs2[0].ConvertTo <string>()
             };
             var objs2idx = 0;
             if (withdist)
             {
                 grr.dist = objs2[++objs2idx].ConvertTo <decimal>();
             }
             if (withhash)
             {
                 grr.hash = objs2[++objs2idx].ConvertTo <long>();
             }
             if (withdoord)
             {
                 var objs3 = objs2[++objs2idx].ConvertTo <decimal[]>();
                 grr.longitude = objs3[0];
                 grr.latitude = objs3[1];
             }
             return grr;
         }).ToArray());
     }
     return((a as List <object>).Select(x => new GeoRadiusResult {
         member = x.ConvertTo <string>()
     }).ToArray());
 }).ThrowOrValue());
Exemplo n.º 4
0
 public object Sort(string key, string byPattern, long offset, long count, string[] getPatterns, Collation?collation, bool alpha, string storeDestination) => Call("SORT"
                                                                                                                                                                   .Input(key)
                                                                                                                                                                   .InputIf(!string.IsNullOrWhiteSpace(byPattern), "BY", byPattern)
                                                                                                                                                                   .InputIf(offset != 0 || count != 0, "LIMIT", offset, count)
                                                                                                                                                                   .InputIf(getPatterns?.Any() == true, getPatterns.Select(a => new[] { "GET", a }).SelectMany(a => a).ToArray())
                                                                                                                                                                   .InputIf(collation != null, collation)
                                                                                                                                                                   .InputIf(alpha, "ALPHA")
                                                                                                                                                                   .InputIf(!string.IsNullOrWhiteSpace(storeDestination), "STORE", storeDestination)
                                                                                                                                                                   .FlagKey(key, storeDestination), rt => rt.ThrowOrValue());
Exemplo n.º 5
0
 public string[] Sort(string key, string byPattern = null, long offset = 0, long count = 0, string[] getPatterns = null, Collation?collation = null, bool alpha = false) => Call("SORT"
                                                                                                                                                                                 .Input(key)
                                                                                                                                                                                 .InputIf(!string.IsNullOrWhiteSpace(byPattern), "BY", byPattern)
                                                                                                                                                                                 .InputIf(offset != 0 || count != 0, "LIMIT", offset, count)
                                                                                                                                                                                 .InputIf(getPatterns?.Any() == true, getPatterns.Select(a => new[] { "GET", a }).SelectMany(a => a).ToArray())
                                                                                                                                                                                 .InputIf(collation != null, collation)
                                                                                                                                                                                 .InputIf(alpha, "ALPHA")
                                                                                                                                                                                 .FlagKey(key), rt => rt.ThrowOrValue <string[]>());
Exemplo n.º 6
0
 public Task <GeoRadiusResult[]> GeoRadiusAsync(string key, decimal longitude, decimal latitude, decimal radius, GeoUnit unit = GeoUnit.m,
                                                bool withdoord = false, bool withdist      = false, bool withhash = false,
                                                long?count     = null, Collation?collation = null) => GeoRadiusAsync("GEORADIUS", key, null, longitude, latitude, radius, unit,
                                                                                                                     withdoord, withdist, withhash, count, collation);
Exemplo n.º 7
0
 public GeoRadiusResult[] GeoRadiusByMember(string key, string member, decimal radius, GeoUnit unit = GeoUnit.m,
                                            bool withdoord = false, bool withdist      = false, bool withhash = false,
                                            long?count     = null, Collation?collation = null) => GeoRadius("GEORADIUSBYMEMBER", key, member, null, null, radius, unit,
                                                                                                            withdoord, withdist, withhash, count, collation);
Exemplo n.º 8
0
 public Task <long> SortStoreAsync(string storeDestination, string key, string byPattern = null, long offset = 0, long count = 0, string[] getPatterns = null, Collation?collation = null, bool alpha = false) => CallAsync("SORT"
                                                                                                                                                                                                                            .InputKey(key)
                                                                                                                                                                                                                            .InputIf(!string.IsNullOrWhiteSpace(byPattern), "BY", byPattern)
                                                                                                                                                                                                                            .InputIf(offset != 0 || count != 0, "LIMIT", offset, count)
                                                                                                                                                                                                                            .InputIf(getPatterns?.Any() == true, getPatterns.Select(a => new[] { "GET", a }).SelectMany(a => a).ToArray())
                                                                                                                                                                                                                            .InputIf(collation != null, collation)
                                                                                                                                                                                                                            .InputIf(alpha, "ALPHA")
                                                                                                                                                                                                                            .InputIf(!string.IsNullOrWhiteSpace(storeDestination), "STORE")
                                                                                                                                                                                                                            .InputKeyIf(!string.IsNullOrWhiteSpace(storeDestination), storeDestination), rt => rt.ThrowOrValue <long>());
Exemplo n.º 9
0
 public object GeoRadiusByMember(string key, string member, decimal radius, GeoUnit unit, bool withdoord, bool withdist, bool withhash, long count, Collation?collation, string storekey, string storedistkey) => Call <object>("GEORADIUSBYMEMBER"
                                                                                                                                                                                                                                .Input(key, member, radius)
                                                                                                                                                                                                                                .InputRaw(unit)
                                                                                                                                                                                                                                .InputIf(withdoord, "WITHCOORD")
                                                                                                                                                                                                                                .InputIf(withdist, "WITHDIST")
                                                                                                                                                                                                                                .InputIf(withhash, "WITHHASH")
                                                                                                                                                                                                                                .InputIf(count != 0, "COUNT", count)
                                                                                                                                                                                                                                .InputIf(collation != null, collation)
                                                                                                                                                                                                                                .InputIf(!string.IsNullOrWhiteSpace(storekey), "STORE", storekey)
                                                                                                                                                                                                                                .InputIf(!string.IsNullOrWhiteSpace(storedistkey), "STOREDIST", storedistkey)
                                                                                                                                                                                                                                .FlagKey(key), rt => rt.ThrowOrValue());