MCPcopy Create free account
hub / github.com/ByteStorage/FlyDB / TestExpireStructure_PEXPIRE

Function TestExpireStructure_PEXPIRE

structure/expiring_key_test.go:42–60  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

40}
41
42func TestExpireStructure_PEXPIRE(t *testing.T) {
43 expire, _ := initExpire()
44 defer expire.db.Close()
45
46 key := "test_key"
47 milliseconds := int64(2000)
48
49 // Test PEXPIRE function
50 expireErr = expire.PEXPIRE(key, milliseconds)
51 assert.Nil(t, expireErr)
52
53 // Wait for the key to expire
54 time.Sleep(time.Millisecond * time.Duration(milliseconds+100))
55
56 // Check if the key has expired
57 ttl, err := expire.TTL(key)
58 assert.Nil(t, err)
59 assert.Equal(t, int64(-2), ttl) // -2 indicates that the key does not exist
60}
61
62func TestExpireStructure_EXPIREAT(t *testing.T) {
63 expire, _ := initExpire()

Callers

nothing calls this directly

Calls 4

initExpireFunction · 0.85
PEXPIREMethod · 0.80
CloseMethod · 0.65
TTLMethod · 0.65

Tested by

no test coverage detected