MCPcopy
hub / github.com/redis/redis-py / test_hexpire_conditions

Function test_hexpire_conditions

tests/test_hash.py:33–47  ·  view source on GitHub ↗
(r)

Source from the content-addressed store, hash-verified

31
32@skip_if_server_version_lt("7.3.240")
33def test_hexpire_conditions(r):
34 r.delete("test:hash")
35 r.hset("test:hash", mapping={"field1": "value1"})
36 assert r.hexpire("test:hash", 2, "field1", xx=True) == [0]
37 assert r.hexpire("test:hash", 2, "field1", nx=True) == [1]
38 assert r.hexpire("test:hash", 1, "field1", xx=True) == [1]
39 assert r.hexpire("test:hash", 2, "field1", nx=True) == [0]
40 time.sleep(1.1)
41 assert r.hexists("test:hash", "field1") is False
42 r.hset("test:hash", "field1", "value1")
43 r.hexpire("test:hash", 2, "field1")
44 assert r.hexpire("test:hash", 1, "field1", gt=True) == [0]
45 assert r.hexpire("test:hash", 1, "field1", lt=True) == [1]
46 time.sleep(1.1)
47 assert r.hexists("test:hash", "field1") is False
48
49
50@skip_if_server_version_lt("7.3.240")

Callers

nothing calls this directly

Calls 5

hsetMethod · 0.80
hexpireMethod · 0.80
hexistsMethod · 0.80
deleteMethod · 0.45
sleepMethod · 0.45

Tested by

no test coverage detected