I am new to Aerospike.. My namespace has multiple sets. I am trying to set different TTLs for different sets in my aerospike dB namespace.
I do not want to use the default-ttl assigned to the namespace, instead I want to set it for each set.
my config
namespace test {
replication-factor 1
memory-size 1G
default-ttl 0
}
i referred to this link https://docs.aerospike.com/server/operations/configure, where it is stating that set specific record policies can be set.
namespace <name> { # Define namespace record policies and storage engine
storage {} # Configure persistence or lack of persistence
set {} # (Optional) Set specific record policies
}
but i am not sure what field should i use to set the ttl for each set. Say, i have two sets in this 'test' namespace named - order
and name
and i want their ttls to be 2hrs and 6 hours respectively.
Any help would be appreciated.
Thanks in advance
All records in aeropsike belong to a namespace, set is just a metadata, like a tag, on the record. default-ttl is the record's remaining life if the client does not specify at create or update. You cannot assign default-ttl by set in the server configuration. (There are some other set specific config parameters, for e.g. disable-eviction, enable-index that are implemented, default-ttl is not one of them.) But you can achieve the same by writing it in your client application.
For each set you can use a different write policy and in that write policy define the ttl for creating or updating records in that specific set. For e.g. in Java client, it is called WritePolicy.expiration, in seconds. In your specific case, you could do 2 hours default-ttl as server config - so orders will get that as default, for name, in client, when creating or updating records in name set, you override server default to 6 hours using WritePolicy.expiration = 3600.