Skip to content

How to store Dio's CancelToken in database column? #1312

Answered by simolus3
sharoonamjid asked this question in Q&A
Discussion options

You must be logged in to vote

It's not possible to store a CancelToken in a database, it's not data. Data persisted in a database survives app restarts, while cancel tokens (and uploads in general) do not.

I think the cleanest approach would be to handle cancellations somewhere out of the database. You could in theory have a global map <int, CancelToken> somewhere. When you create a new token, you increase some counter and store it in that map. A type converter could then store the token's id an look it up as necessary. But that's really not a great solution, I wouldn't store cancel tokens in a database because they don't persist.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@sharoonamjid
Comment options

@simolus3
Comment options

@sharoonamjid
Comment options

Answer selected by sharoonamjid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants