redis.hset(hash_name, field, value)

assert redis.hpexpire(hash_name, field, 1000) == [1]

Arguments

key
str
required

The key of the hash.

fields
Union[str, List[str]]
required

The field or list of fields within the hash to set the expiry for.

milliseconds
Union[int, datetime.timedelta]
required

The timeout in milliseconds as an integer or a datetime.timedelta object.

nx
bool

Set expiry only when the field has no expiry. Defaults to False.

xx
bool

Set expiry only when the field has an existing expiry. Defaults to False.

gt
bool

Set expiry only when the new expiry is greater than the current one. Defaults to False.

lt
bool

Set expiry only when the new expiry is less than the current one. Defaults to False.

Response

A list of integers indicating whether the expiry was successfully set.

  • -2 if the field does not exist in the hash or if key doesn’t exist.
  • 0 if the expiration was not set due to the condition.
  • 1 if the expiration was successfully set.
  • 2 if called with 0 seconds/milliseconds or a past Unix time.

For more details, see HPEXPIRE documentation.

redis.hset(hash_name, field, value)

assert redis.hpexpire(hash_name, field, 1000) == [1]