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

Function TestExpireStructure_PEXPIREAT

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

Source from the content-addressed store, hash-verified

80}
81
82func TestExpireStructure_PEXPIREAT(t *testing.T) {
83 expire, _ := initExpire()
84 defer expire.db.Close()
85
86 key := "test_key"
87 timestamp := time.Now().Add(time.Second*2).Unix() * 1000
88
89 // Test PEXPIREAT function
90 expireErr = expire.PEXPIREAT(key, timestamp)
91 assert.Nil(t, expireErr)
92
93 // Wait for the key to expire
94 time.Sleep(time.Second * 3)
95
96 // Check if the key has expired
97 ttl, err := expire.TTL(key)
98 assert.Nil(t, err)
99 assert.Equal(t, int64(-2), ttl) // -2 indicates that the key does not exist
100}
101
102func TestExpireStructure_TTL(t *testing.T) {
103 expire, _ := initExpire()

Callers

nothing calls this directly

Calls 5

initExpireFunction · 0.85
AddMethod · 0.80
PEXPIREATMethod · 0.80
CloseMethod · 0.65
TTLMethod · 0.65

Tested by

no test coverage detected