Skip to content

Core Options

Home / glide_shared / core_options

glide_shared.commands.core_options.ConditionalChange

Bases: Enum

A condition to the SET, ZADD and GEOADD commands.

Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/commands/core_options.py
27
28
29
30
31
32
33
34
35
36
class ConditionalChange(Enum):
    """
    A condition to the `SET`, `ZADD` and `GEOADD` commands.
    """

    ONLY_IF_EXISTS = "XX"
    """ Only update key / elements that already exist. Equivalent to `XX` in the Valkey API. """

    ONLY_IF_DOES_NOT_EXIST = "NX"
    """ Only set key / add elements that does not already exist. Equivalent to `NX` in the Valkey API. """

ONLY_IF_DOES_NOT_EXIST = 'NX' class-attribute instance-attribute

Only set key / add elements that does not already exist. Equivalent to NX in the Valkey API.

ONLY_IF_EXISTS = 'XX' class-attribute instance-attribute

Only update key / elements that already exist. Equivalent to XX in the Valkey API.

glide_shared.commands.core_options.ExpiryType

Bases: Enum

SET option: The type of the expiry.

Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/commands/core_options.py
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
class ExpiryType(Enum):
    """
    SET option: The type of the expiry.
    """

    SEC = 0, Union[int, timedelta]
    """
    Set the specified expire time, in seconds. Equivalent to `EX` in the Valkey API.
    """

    MILLSEC = 1, Union[int, timedelta]
    """
    Set the specified expire time, in milliseconds. Equivalent to `PX` in the Valkey API.
    """

    UNIX_SEC = 2, Union[int, datetime]
    """
    Set the specified Unix time at which the key will expire, in seconds. Equivalent to `EXAT` in the Valkey API.
    """

    UNIX_MILLSEC = 3, Union[int, datetime]
    """
    Set the specified Unix time at which the key will expire, in milliseconds. Equivalent to `PXAT` in the Valkey API.
    """

    KEEP_TTL = 4, Type[None]
    """
    Retain the time to live associated with the key. Equivalent to `KEEPTTL` in the Valkey API.
    """

KEEP_TTL = (4, Type[None]) class-attribute instance-attribute

Retain the time to live associated with the key. Equivalent to KEEPTTL in the Valkey API.

MILLSEC = (1, Union[int, timedelta]) class-attribute instance-attribute

Set the specified expire time, in milliseconds. Equivalent to PX in the Valkey API.

SEC = (0, Union[int, timedelta]) class-attribute instance-attribute

Set the specified expire time, in seconds. Equivalent to EX in the Valkey API.

UNIX_MILLSEC = (3, Union[int, datetime]) class-attribute instance-attribute

Set the specified Unix time at which the key will expire, in milliseconds. Equivalent to PXAT in the Valkey API.

UNIX_SEC = (2, Union[int, datetime]) class-attribute instance-attribute

Set the specified Unix time at which the key will expire, in seconds. Equivalent to EXAT in the Valkey API.

glide_shared.commands.core_options.ExpiryTypeGetEx

Bases: Enum

GetEx option: The type of the expiry.

Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/commands/core_options.py
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
class ExpiryTypeGetEx(Enum):
    """
    GetEx option: The type of the expiry.
    """

    SEC = 0, Union[int, timedelta]
    """ Set the specified expire time, in seconds. Equivalent to `EX` in the Valkey API. """

    MILLSEC = 1, Union[int, timedelta]
    """ Set the specified expire time, in milliseconds. Equivalent to `PX` in the Valkey API. """

    UNIX_SEC = 2, Union[int, datetime]
    """ Set the specified Unix time at which the key will expire, in seconds. Equivalent to `EXAT` in the Valkey API. """

    UNIX_MILLSEC = 3, Union[int, datetime]
    """ Set the specified Unix time at which the key will expire, in milliseconds. Equivalent to `PXAT` in the Valkey API. """

    PERSIST = 4, Type[None]
    """ Remove the time to live associated with the key. Equivalent to `PERSIST` in the Valkey API. """

MILLSEC = (1, Union[int, timedelta]) class-attribute instance-attribute

Set the specified expire time, in milliseconds. Equivalent to PX in the Valkey API.

PERSIST = (4, Type[None]) class-attribute instance-attribute

Remove the time to live associated with the key. Equivalent to PERSIST in the Valkey API.

SEC = (0, Union[int, timedelta]) class-attribute instance-attribute

Set the specified expire time, in seconds. Equivalent to EX in the Valkey API.

UNIX_MILLSEC = (3, Union[int, datetime]) class-attribute instance-attribute

Set the specified Unix time at which the key will expire, in milliseconds. Equivalent to PXAT in the Valkey API.

UNIX_SEC = (2, Union[int, datetime]) class-attribute instance-attribute

Set the specified Unix time at which the key will expire, in seconds. Equivalent to EXAT in the Valkey API.

glide_shared.commands.core_options.InfoSection

Bases: Enum

INFO option: a specific section of information:

When no parameter is provided, the default option is assumed.

Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/commands/core_options.py
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
class InfoSection(Enum):
    """
    INFO option: a specific section of information:

    When no parameter is provided, the default option is assumed.
    """

    SERVER = "server"
    """ General information about the server """

    CLIENTS = "clients"
    """ Client connections section """

    MEMORY = "memory"
    """ Memory consumption related information """

    PERSISTENCE = "persistence"
    """ RDB and AOF related information """

    STATS = "stats"
    """ General statistics """

    REPLICATION = "replication"
    """ Master/replica replication information """

    CPU = "cpu"
    """ CPU consumption statistics """

    COMMAND_STATS = "commandstats"
    """ Valkey command statistics """

    LATENCY_STATS = "latencystats"
    """ Valkey command latency percentile distribution statistics """

    SENTINEL = "sentinel"
    """ Valkey Sentinel section (only applicable to Sentinel instances) """

    CLUSTER = "cluster"
    """ Valkey Cluster section """

    MODULES = "modules"
    """ Modules section """

    KEYSPACE = "keyspace"
    """ Database related statistics """

    ERROR_STATS = "errorstats"
    """ Valkey error statistics """

    ALL = "all"
    """ Return all sections (excluding module generated ones) """

    DEFAULT = "default"
    """ Return only the default set of sections """

    EVERYTHING = "everything"
    """ Includes all and modules """

ALL = 'all' class-attribute instance-attribute

Return all sections (excluding module generated ones)

CLIENTS = 'clients' class-attribute instance-attribute

Client connections section

CLUSTER = 'cluster' class-attribute instance-attribute

Valkey Cluster section

COMMAND_STATS = 'commandstats' class-attribute instance-attribute

Valkey command statistics

CPU = 'cpu' class-attribute instance-attribute

CPU consumption statistics

DEFAULT = 'default' class-attribute instance-attribute

Return only the default set of sections

ERROR_STATS = 'errorstats' class-attribute instance-attribute

Valkey error statistics

EVERYTHING = 'everything' class-attribute instance-attribute

Includes all and modules

KEYSPACE = 'keyspace' class-attribute instance-attribute

Database related statistics

LATENCY_STATS = 'latencystats' class-attribute instance-attribute

Valkey command latency percentile distribution statistics

MEMORY = 'memory' class-attribute instance-attribute

Memory consumption related information

MODULES = 'modules' class-attribute instance-attribute

Modules section

PERSISTENCE = 'persistence' class-attribute instance-attribute

RDB and AOF related information

REPLICATION = 'replication' class-attribute instance-attribute

Master/replica replication information

SENTINEL = 'sentinel' class-attribute instance-attribute

Valkey Sentinel section (only applicable to Sentinel instances)

SERVER = 'server' class-attribute instance-attribute

General information about the server

STATS = 'stats' class-attribute instance-attribute

General statistics

glide_shared.commands.core_options.ExpireOptions

Bases: Enum

EXPIRE option: options for setting key expiry.

Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/commands/core_options.py
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
class ExpireOptions(Enum):
    """
    EXPIRE option: options for setting key expiry.
    """

    HasNoExpiry = "NX"
    """ Set expiry only when the key has no expiry (Equivalent to "NX" in Valkey). """

    HasExistingExpiry = "XX"
    """ Set expiry only when the key has an existing expiry (Equivalent to "XX" in Valkey). """

    NewExpiryGreaterThanCurrent = "GT"
    """
    Set expiry only when the new expiry is greater than the current one (Equivalent to "GT" in Valkey).
    """

    NewExpiryLessThanCurrent = "LT"
    """
    Set expiry only when the new expiry is less than the current one (Equivalent to "LT" in Valkey).
    """

HasExistingExpiry = 'XX' class-attribute instance-attribute

Set expiry only when the key has an existing expiry (Equivalent to "XX" in Valkey).

HasNoExpiry = 'NX' class-attribute instance-attribute

Set expiry only when the key has no expiry (Equivalent to "NX" in Valkey).

NewExpiryGreaterThanCurrent = 'GT' class-attribute instance-attribute

Set expiry only when the new expiry is greater than the current one (Equivalent to "GT" in Valkey).

NewExpiryLessThanCurrent = 'LT' class-attribute instance-attribute

Set expiry only when the new expiry is less than the current one (Equivalent to "LT" in Valkey).

glide_shared.commands.core_options.UpdateOptions

Bases: Enum

Options for updating elements of a sorted set key.

Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/commands/core_options.py
199
200
201
202
203
204
205
206
207
208
class UpdateOptions(Enum):
    """
    Options for updating elements of a sorted set key.
    """

    LESS_THAN = "LT"
    """ Only update existing elements if the new score is less than the current score. """

    GREATER_THAN = "GT"
    """ Only update existing elements if the new score is greater than the current score. """

GREATER_THAN = 'GT' class-attribute instance-attribute

Only update existing elements if the new score is greater than the current score.

LESS_THAN = 'LT' class-attribute instance-attribute

Only update existing elements if the new score is less than the current score.

glide_shared.commands.core_options.ExpirySet

SET option: Represents the expiry type and value to be executed with "SET" command.

Attributes:

Name Type Description
cmd_arg str

The expiry type.

value str

The value for the expiry type.

Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/commands/core_options.py
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
class ExpirySet:
    """
    SET option: Represents the expiry type and value to be executed with "SET" command.

    Attributes:
        cmd_arg (str): The expiry type.
        value (str): The value for the expiry type.
    """

    def __init__(
        self,
        expiry_type: ExpiryType,
        value: Optional[Union[int, datetime, timedelta]],
    ) -> None:
        self.set_expiry_type_and_value(expiry_type, value)

    def __eq__(self, other: "object") -> bool:
        if not isinstance(other, ExpirySet):
            return NotImplemented
        return self.expiry_type == other.expiry_type and self.value == other.value

    def set_expiry_type_and_value(
        self, expiry_type: ExpiryType, value: Optional[Union[int, datetime, timedelta]]
    ):
        """
        Args:
            expiry_type (ExpiryType): The expiry type.
            value (Optional[Union[int, datetime, timedelta]]): The value of the expiration type. The type of expiration
                determines the type of expiration value:

                    - SEC: Union[int, timedelta]
                    - MILLSEC: Union[int, timedelta]
                    - UNIX_SEC: Union[int, datetime]
                    - UNIX_MILLSEC: Union[int, datetime]
                    - KEEP_TTL: Type[None]
        """
        if not isinstance(value, get_args(expiry_type.value[1])):
            raise ValueError(
                f"The value of {expiry_type} should be of type {expiry_type.value[1]}"
            )
        self.expiry_type = expiry_type
        if self.expiry_type == ExpiryType.SEC:
            self.cmd_arg = "EX"
            if isinstance(value, timedelta):
                value = int(value.total_seconds())
        elif self.expiry_type == ExpiryType.MILLSEC:
            self.cmd_arg = "PX"
            if isinstance(value, timedelta):
                value = int(value.total_seconds() * 1000)
        elif self.expiry_type == ExpiryType.UNIX_SEC:
            self.cmd_arg = "EXAT"
            if isinstance(value, datetime):
                value = int(value.timestamp())
        elif self.expiry_type == ExpiryType.UNIX_MILLSEC:
            self.cmd_arg = "PXAT"
            if isinstance(value, datetime):
                value = int(value.timestamp() * 1000)
        elif self.expiry_type == ExpiryType.KEEP_TTL:
            self.cmd_arg = "KEEPTTL"
        self.value = str(value) if value else None

    def get_cmd_args(self) -> List[str]:
        return [self.cmd_arg] if self.value is None else [self.cmd_arg, self.value]

set_expiry_type_and_value(expiry_type, value)

Parameters:

Name Type Description Default
expiry_type ExpiryType

The expiry type.

required
value Optional[Union[int, datetime, timedelta]]

The value of the expiration type. The type of expiration determines the type of expiration value:

- SEC: Union[int, timedelta]
- MILLSEC: Union[int, timedelta]
- UNIX_SEC: Union[int, datetime]
- UNIX_MILLSEC: Union[int, datetime]
- KEEP_TTL: Type[None]
required
Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/commands/core_options.py
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
def set_expiry_type_and_value(
    self, expiry_type: ExpiryType, value: Optional[Union[int, datetime, timedelta]]
):
    """
    Args:
        expiry_type (ExpiryType): The expiry type.
        value (Optional[Union[int, datetime, timedelta]]): The value of the expiration type. The type of expiration
            determines the type of expiration value:

                - SEC: Union[int, timedelta]
                - MILLSEC: Union[int, timedelta]
                - UNIX_SEC: Union[int, datetime]
                - UNIX_MILLSEC: Union[int, datetime]
                - KEEP_TTL: Type[None]
    """
    if not isinstance(value, get_args(expiry_type.value[1])):
        raise ValueError(
            f"The value of {expiry_type} should be of type {expiry_type.value[1]}"
        )
    self.expiry_type = expiry_type
    if self.expiry_type == ExpiryType.SEC:
        self.cmd_arg = "EX"
        if isinstance(value, timedelta):
            value = int(value.total_seconds())
    elif self.expiry_type == ExpiryType.MILLSEC:
        self.cmd_arg = "PX"
        if isinstance(value, timedelta):
            value = int(value.total_seconds() * 1000)
    elif self.expiry_type == ExpiryType.UNIX_SEC:
        self.cmd_arg = "EXAT"
        if isinstance(value, datetime):
            value = int(value.timestamp())
    elif self.expiry_type == ExpiryType.UNIX_MILLSEC:
        self.cmd_arg = "PXAT"
        if isinstance(value, datetime):
            value = int(value.timestamp() * 1000)
    elif self.expiry_type == ExpiryType.KEEP_TTL:
        self.cmd_arg = "KEEPTTL"
    self.value = str(value) if value else None

glide_shared.commands.core_options.ExpiryGetEx

GetEx option: Represents the expiry type and value to be executed with "GetEx" command.

Attributes:

Name Type Description
cmd_arg str

The expiry type.

value str

The value for the expiry type.

Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/commands/core_options.py
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
class ExpiryGetEx:
    """
    GetEx option: Represents the expiry type and value to be executed with "GetEx" command.

    Attributes:
        cmd_arg (str): The expiry type.
        value (str): The value for the expiry type.
    """

    def __init__(
        self,
        expiry_type: ExpiryTypeGetEx,
        value: Optional[Union[int, datetime, timedelta]],
    ) -> None:
        self.set_expiry_type_and_value(expiry_type, value)

    def set_expiry_type_and_value(
        self,
        expiry_type: ExpiryTypeGetEx,
        value: Optional[Union[int, datetime, timedelta]],
    ):
        """
        Args:
            expiry_type (ExpiryType): The expiry type.
            value (Optional[Union[int, datetime, timedelta]]): The value of the expiration type. The type of expiration
                determines the type of expiration value:

                    - SEC: Union[int, timedelta]
                    - MILLSEC: Union[int, timedelta]
                    - UNIX_SEC: Union[int, datetime]
                    - UNIX_MILLSEC: Union[int, datetime]
                    - PERSIST: Type[None]
        """
        if not isinstance(value, get_args(expiry_type.value[1])):
            raise ValueError(
                f"The value of {expiry_type} should be of type {expiry_type.value[1]}"
            )
        self.expiry_type = expiry_type
        if self.expiry_type == ExpiryTypeGetEx.SEC:
            self.cmd_arg = "EX"
            if isinstance(value, timedelta):
                value = int(value.total_seconds())
        elif self.expiry_type == ExpiryTypeGetEx.MILLSEC:
            self.cmd_arg = "PX"
            if isinstance(value, timedelta):
                value = int(value.total_seconds() * 1000)
        elif self.expiry_type == ExpiryTypeGetEx.UNIX_SEC:
            self.cmd_arg = "EXAT"
            if isinstance(value, datetime):
                value = int(value.timestamp())
        elif self.expiry_type == ExpiryTypeGetEx.UNIX_MILLSEC:
            self.cmd_arg = "PXAT"
            if isinstance(value, datetime):
                value = int(value.timestamp() * 1000)
        elif self.expiry_type == ExpiryTypeGetEx.PERSIST:
            self.cmd_arg = "PERSIST"
        self.value = str(value) if value else None

    def get_cmd_args(self) -> List[str]:
        return [self.cmd_arg] if self.value is None else [self.cmd_arg, self.value]

set_expiry_type_and_value(expiry_type, value)

Parameters:

Name Type Description Default
expiry_type ExpiryType

The expiry type.

required
value Optional[Union[int, datetime, timedelta]]

The value of the expiration type. The type of expiration determines the type of expiration value:

- SEC: Union[int, timedelta]
- MILLSEC: Union[int, timedelta]
- UNIX_SEC: Union[int, datetime]
- UNIX_MILLSEC: Union[int, datetime]
- PERSIST: Type[None]
required
Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/commands/core_options.py
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
def set_expiry_type_and_value(
    self,
    expiry_type: ExpiryTypeGetEx,
    value: Optional[Union[int, datetime, timedelta]],
):
    """
    Args:
        expiry_type (ExpiryType): The expiry type.
        value (Optional[Union[int, datetime, timedelta]]): The value of the expiration type. The type of expiration
            determines the type of expiration value:

                - SEC: Union[int, timedelta]
                - MILLSEC: Union[int, timedelta]
                - UNIX_SEC: Union[int, datetime]
                - UNIX_MILLSEC: Union[int, datetime]
                - PERSIST: Type[None]
    """
    if not isinstance(value, get_args(expiry_type.value[1])):
        raise ValueError(
            f"The value of {expiry_type} should be of type {expiry_type.value[1]}"
        )
    self.expiry_type = expiry_type
    if self.expiry_type == ExpiryTypeGetEx.SEC:
        self.cmd_arg = "EX"
        if isinstance(value, timedelta):
            value = int(value.total_seconds())
    elif self.expiry_type == ExpiryTypeGetEx.MILLSEC:
        self.cmd_arg = "PX"
        if isinstance(value, timedelta):
            value = int(value.total_seconds() * 1000)
    elif self.expiry_type == ExpiryTypeGetEx.UNIX_SEC:
        self.cmd_arg = "EXAT"
        if isinstance(value, datetime):
            value = int(value.timestamp())
    elif self.expiry_type == ExpiryTypeGetEx.UNIX_MILLSEC:
        self.cmd_arg = "PXAT"
        if isinstance(value, datetime):
            value = int(value.timestamp() * 1000)
    elif self.expiry_type == ExpiryTypeGetEx.PERSIST:
        self.cmd_arg = "PERSIST"
    self.value = str(value) if value else None

glide_shared.commands.core_options.InsertPosition

Bases: Enum

Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/commands/core_options.py
338
339
340
class InsertPosition(Enum):
    BEFORE = "BEFORE"
    AFTER = "AFTER"

glide_shared.commands.core_options.FlushMode

Bases: Enum

Defines flushing mode for:

FLUSHALL command and FUNCTION FLUSH command.

See FLUSHAL and FUNCTION-FLUSH for details

SYNC was introduced in version 6.2.0.

Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/commands/core_options.py
343
344
345
346
347
348
349
350
351
352
353
354
355
356
class FlushMode(Enum):
    """
    Defines flushing mode for:

    `FLUSHALL` command and `FUNCTION FLUSH` command.

    See [FLUSHAL](https://valkey.io/commands/flushall/) and [FUNCTION-FLUSH](https://valkey.io/commands/function-flush/)
    for details

    SYNC was introduced in version 6.2.0.
    """

    ASYNC = "ASYNC"
    SYNC = "SYNC"

glide_shared.commands.core_options.FunctionRestorePolicy

Bases: Enum

Options for the FUNCTION RESTORE command.

Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/commands/core_options.py
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
class FunctionRestorePolicy(Enum):
    """
    Options for the FUNCTION RESTORE command.
    """

    APPEND = "APPEND"
    """ Appends the restored libraries to the existing libraries and aborts on collision. This is the default policy. """

    FLUSH = "FLUSH"
    """ Deletes all existing libraries before restoring the payload. """

    REPLACE = "REPLACE"
    """
    Appends the restored libraries to the existing libraries, replacing any existing ones in case
    of name collisions. Note that this policy doesn't prevent function name collisions, only libraries.
    """

APPEND = 'APPEND' class-attribute instance-attribute

Appends the restored libraries to the existing libraries and aborts on collision. This is the default policy.

FLUSH = 'FLUSH' class-attribute instance-attribute

Deletes all existing libraries before restoring the payload.

REPLACE = 'REPLACE' class-attribute instance-attribute

Appends the restored libraries to the existing libraries, replacing any existing ones in case of name collisions. Note that this policy doesn't prevent function name collisions, only libraries.