Update ttl for all records in aerospike

Viewed 1527

I was stuck in a situation that I have initialised a namesapce with default-ttl to 30 days. There was about 5 million data with that (30-day calculated) ttl-value. Actually, my requirement is that ttl should be zero(0), but It(ttl-30d) was kept with unaware or un-recognise.

So, Now I want to update prev(old) 5 million data with new ttl-value (Zero).

I've checked/tried "set-disable-eviction true", but it is not working, it is removing data according to (old)ttl-value.

How do I overcome out this? (and I want to retrieve the removed data, How can I?).

Someone help me.

2 Answers

Using a Python script would be easier if you have more complex logic, with filters etc.

zero_ttl_operation = [operations.touch(-1)]
query = client.query(namespace, set_name)
query.add_ops(zero_ttl_operation)
policy = {}
job = query.execute_background(policy)
print(f'executing job {job}')
while True:
    response = client.job_info(job, aerospike.JOB_SCAN, policy={'timeout': 60000})
    print(f'job status: {response}')
    if response['status'] != aerospike.JOB_STATUS_INPROGRESS:
        break
    time.sleep(0.5)

Aerospike v6 and Python SDK v7.

Related