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

Function TestExpireStructure_PTTL

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

Source from the content-addressed store, hash-verified

119}
120
121func TestExpireStructure_PTTL(t *testing.T) {
122 expire, _ := initExpire()
123 defer expire.db.Close()
124
125 key := "test_key"
126 milliseconds := int64(2000)
127
128 // Test PTTL function with an existing key
129 expire.PEXPIRE(key, milliseconds)
130 ttl, err := expire.PTTL(key)
131 assert.Nil(t, err)
132 assert.True(t, ttl > 0) // TTL should be positive
133
134 // Test PTTL function with a non-existing key
135 ttl, err = expire.PTTL("non_existing_key")
136 assert.Nil(t, err)
137 assert.Equal(t, int64(-2), ttl) // -2 indicates that the key does not exist
138}
139
140func TestExpireStructure_PERSIST(t *testing.T) {
141 expire, _ := initExpire()

Callers

nothing calls this directly

Calls 4

initExpireFunction · 0.85
PEXPIREMethod · 0.80
PTTLMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected