Best practice for canister upgrade with task created by ic-cdk-timers

Hi dev,

my canister using ic-cdk-timers for schedule random task by business logic

due to this document, it said

Canister upgrades: The library keeps a global list of multiple and periodic tasks inside the canister heap. During a canister upgrade, a fresh WebAssembly state is created, all the timers are deactivated, and the list of timers is cleared. It is up to the canister developer to serialize the timers in the canister_pre_upgrade and reactivate them in the canister_post_upgrade method if needed.

but the ic-cdk-timers didn’t expose the threadlocal.
How can I access the ic-cdk-timers heap memory while upgrade canister.
What is the best practice here?

One way (and how we do it in NNS canisters like this
) is to store the timing information elsewhere as part of the canister state. Such canister state can be persisted in different ways (in stable memory, or stored in heap memory while being serialized/deserialized during upgrade). Then in the post_upgrade, the timers can be re-scheduled based on the canister state.