Skip to content

Hash Commands

Bases: BaseCommand

Mixin for Redis Hash commands (e.g. HGET, HSET, HDEL).

Source code in pyredis/commands/hash.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
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
class Hash(BaseCommand):
    """Mixin for Redis Hash commands (e.g. HGET, HSET, HDEL)."""

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

__init__()

Source code in pyredis/commands/hash.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

hdel(*args)

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

hexists(*args)

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

hget(*args)

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

hgetall(*args)

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

hincrby(*args)

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

hincrbyfloat(*args)

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

hkeys(*args)

Source code in pyredis/commands/hash.py
70
71
72
73
74
75
76
77
78
def hkeys(self, *args):
    if self._cluster:
        return self.execute(
            *[b"HKEYS", *args],
            shard_key=args[0]
        )
    return self.execute(
        *[b"HKEYS", *args]
    )

hlen(*args)

Source code in pyredis/commands/hash.py
80
81
82
83
84
85
86
87
88
def hlen(self, *args):
    if self._cluster:
        return self.execute(
            *[b"HLEN", *args],
            shard_key=args[0]
        )
    return self.execute(
        *[b"HLEN", *args]
    )

hmget(*args)

Source code in pyredis/commands/hash.py
90
91
92
93
94
95
96
97
98
def hmget(self, *args):
    if self._cluster:
        return self.execute(
            *[b"HMGET", *args],
            shard_key=args[0]
        )
    return self.execute(
        *[b"HMGET", *args]
    )

hmset(*args)

Source code in pyredis/commands/hash.py
100
101
102
103
104
105
106
107
108
def hmset(self, *args):
    if self._cluster:
        return self.execute(
            *[b"HMSET", *args],
            shard_key=args[0]
        )
    return self.execute(
        *[b"HMSET", *args]
    )

hscan(*args)

Source code in pyredis/commands/hash.py
150
151
152
153
154
155
156
157
158
def hscan(self, *args):
    if self._cluster:
        return self.execute(
            *[b"HSCAN", *args],
            shard_key=args[0]
        )
    return self.execute(
        *[b"HSCAN", *args]
    )

hset(*args)

Source code in pyredis/commands/hash.py
110
111
112
113
114
115
116
117
118
def hset(self, *args):
    if self._cluster:
        return self.execute(
            *[b"HSET", *args],
            shard_key=args[0]
        )
    return self.execute(
        *[b"HSET", *args]
    )

hsetnx(*args)

Source code in pyredis/commands/hash.py
120
121
122
123
124
125
126
127
128
def hsetnx(self, *args):
    if self._cluster:
        return self.execute(
            *[b"HSETNX", *args],
            shard_key=args[0]
        )
    return self.execute(
        *[b"HSETNX", *args]
    )

hstrlen(*args)

Source code in pyredis/commands/hash.py
130
131
132
133
134
135
136
137
138
def hstrlen(self, *args):
    if self._cluster:
        return self.execute(
            *[b"HSTRLEN", *args],
            shard_key=args[0]
        )
    return self.execute(
        *[b"HSTRLEN", *args]
    )

hvals(*args)

Source code in pyredis/commands/hash.py
140
141
142
143
144
145
146
147
148
def hvals(self, *args):
    if self._cluster:
        return self.execute(
            *[b"HVALS", *args],
            shard_key=args[0]
        )
    return self.execute(
        *[b"HVALS", *args]
    )