Skip to content

Geo Commands

Bases: BaseCommand

Mixin for Redis Geo (spatial/geographic) commands (e.g. GEOADD, GEODIST).

Source code in pyredis/commands/geo.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
class Geo(BaseCommand):
    """Mixin for Redis Geo (spatial/geographic) commands (e.g. GEOADD, GEODIST)."""

    def __init__(self):
        super().__init__()

    def geoadd(self, *args):
        if self._cluster:
            return self.execute(
                *[b"GEOADD", *args],
                shard_key=args[0]
            )
        return self.execute(
            *[b"GEOADD", *args]
        )

    def geodist(self, *args):
        if self._cluster:
            return self.execute(
                *[b"GEODIST", *args],
                shard_key=args[0]
            )
        return self.execute(
            *[b"GEODIST", *args]
        )

    def geohash(self, *args):
        if self._cluster:
            return self.execute(
                *[b"GEOHASH", *args],
                shard_key=args[0]
            )
        return self.execute(
            *[b"GEOHASH", *args]
        )

    def georadius(self, *args):
        if self._cluster:
            return self.execute(
                *[b"GEORADIUS", *args],
                shard_key=args[0]
            )
        return self.execute(
            *[b"GEORADIUS", *args]
        )

    def geopos(self, *args):
        if self._cluster:
            return self.execute(
                *[b"GEOPOS", *args],
                shard_key=args[0]
            )
        return self.execute(
            *[b"GEOPOS", *args]
        )

    def georadiusbymember(self, *args):
        if self._cluster:
            return self.execute(
                *[b"GEORADIUSBYMEMBER", *args],
                shard_key=args[0]
            )
        return self.execute(
            *[b"GEORADIUSBYMEMBER", *args]
        )

__init__()

Source code in pyredis/commands/geo.py
7
8
def __init__(self):
    super().__init__()

execute(*args, **kwargs)

Source code in pyredis/commands/base.py
5
6
def execute(self, *args, **kwargs):
    raise NotImplementedError

geoadd(*args)

Source code in pyredis/commands/geo.py
10
11
12
13
14
15
16
17
18
def geoadd(self, *args):
    if self._cluster:
        return self.execute(
            *[b"GEOADD", *args],
            shard_key=args[0]
        )
    return self.execute(
        *[b"GEOADD", *args]
    )

geodist(*args)

Source code in pyredis/commands/geo.py
20
21
22
23
24
25
26
27
28
def geodist(self, *args):
    if self._cluster:
        return self.execute(
            *[b"GEODIST", *args],
            shard_key=args[0]
        )
    return self.execute(
        *[b"GEODIST", *args]
    )

geohash(*args)

Source code in pyredis/commands/geo.py
30
31
32
33
34
35
36
37
38
def geohash(self, *args):
    if self._cluster:
        return self.execute(
            *[b"GEOHASH", *args],
            shard_key=args[0]
        )
    return self.execute(
        *[b"GEOHASH", *args]
    )

geopos(*args)

Source code in pyredis/commands/geo.py
50
51
52
53
54
55
56
57
58
def geopos(self, *args):
    if self._cluster:
        return self.execute(
            *[b"GEOPOS", *args],
            shard_key=args[0]
        )
    return self.execute(
        *[b"GEOPOS", *args]
    )

georadius(*args)

Source code in pyredis/commands/geo.py
40
41
42
43
44
45
46
47
48
def georadius(self, *args):
    if self._cluster:
        return self.execute(
            *[b"GEORADIUS", *args],
            shard_key=args[0]
        )
    return self.execute(
        *[b"GEORADIUS", *args]
    )

georadiusbymember(*args)

Source code in pyredis/commands/geo.py
60
61
62
63
64
65
66
67
68
def georadiusbymember(self, *args):
    if self._cluster:
        return self.execute(
            *[b"GEORADIUSBYMEMBER", *args],
            shard_key=args[0]
        )
    return self.execute(
        *[b"GEORADIUSBYMEMBER", *args]
    )