#KV vs DO

11 messages · Page 1 of 1 (latest)

marble quail
#

I've been building workers and leveraging KVs to create dynamic content. However, I've come to the realization that how I'm using one of my KVs is super susceptible to race condition issues, so I started looking at DOs.

My question is, are there any "gotchas" I should be concerned with when using DOs? Any "it costs more because it uses more ___" or alike? Would using both essentially "double" in transaction availability (not literally but assuming it were balanced) since they each have their own pool?

It doesn't seem like too much to transition parts from KV to DO, but I also know I'd be flying blind with DOs without a helper script to query/output, so I'm also curious how y'all handle that.

neon night
marble quail
#

it'll be a small load. it's only calculating votes from top.gg API as well as a cron that checks them every 5 mins.

#

so when a user votes, it updates the timestamp and adds to their counter. KV can probably handle it as-is for a while, but I also don't want to have to deal with moving the data lol

#

I guess the real issue would be vote webhook and cron triggering at the same time and one of them not updating as a result

neon night
marble quail
#

oh wait I think I misunderstood. I thought DOs were a different storage container of sorts. I didn't realize it's just an engine that sits between workers and the KV or SQLite. I guess my mention of "increased transaction availability" was way off then lol

neon night
marble quail
#

Gotcha. So my worker currently takes webhook requests for every time someone clicks "Vote" on the bot listing (can only vote once every 12H). The cron runs every 5 mintes to see if the 12H has lapsed for anyone, then perform actions. It also resets vote streaks if they don't vote within an alloted timeframe (say 24H).

neon night
#

And you can even just not schedule an event if it isn't needed, so if the user hasn't done anything in the last 24 hours, there isn't a reason to fire an alarm at all