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

Function TestExpireStructure_TTL

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

Source from the content-addressed store, hash-verified

100}
101
102func TestExpireStructure_TTL(t *testing.T) {
103 expire, _ := initExpire()
104 defer expire.db.Close()
105
106 key := "test_key"
107 seconds := int64(2)
108
109 // Test TTL function with an existing key
110 expire.EXPIRE(key, seconds)
111 ttl, err := expire.TTL(key)
112 assert.Nil(t, err)
113 assert.True(t, ttl > 0) // TTL should be positive
114
115 // Test TTL function with a non-existing key
116 ttl, err = expire.TTL("non_existing_key")
117 assert.Nil(t, err)
118 assert.Equal(t, int64(-2), ttl) // -2 indicates that the key does not exist
119}
120
121func TestExpireStructure_PTTL(t *testing.T) {
122 expire, _ := initExpire()

Callers

nothing calls this directly

Calls 4

initExpireFunction · 0.85
EXPIREMethod · 0.80
CloseMethod · 0.65
TTLMethod · 0.65

Tested by

no test coverage detected