I am trying to get the ttl of an object using GetHeader. However it seems the expiration returned is different from the one I set.
Here is the code:
package main
import (
"fmt"
"github.com/aerospike/aerospike-client-go"
)
func main() {
policy := aerospike.NewClientPolicy()
// We need to request prole replicas in order to distribute
// reads across both master and prole nodes
policy.RequestProleReplicas = true
client, err := aerospike.NewClientWithPolicy(policy, "172.28.128.3", 3000)
if err != nil {
panic(err)
}
writePolicy := aerospike.NewWritePolicy(0, 2)
key, keyErr := aerospike.NewKey("cache", "test_as_record", "abc")
if keyErr != nil {
panic(keyErr)
}
putErr := client.Put(writePolicy, key, aerospike.BinMap{
"bin1": "value1",
})
if putErr != nil {
panic(putErr)
}
readPolicy := aerospike.NewPolicy()
value, headerErr := client.GetHeader(readPolicy, key)
if headerErr != nil {
panic(headerErr)
}
fmt.Printf("Got Expiration: %d, Gen: %d\n", value.Expiration, value.Generation)
}
This returns
Got Expiration: 4294966404, Gen: 1
I expected it to return 2? From the docs and code it seems this should be actual number of seconds: aerospike-client-go/record.go at master · aerospike/aerospike-client-go · GitHub
The record is expiring fine.