https://discord.cloudflare.com logo
Join Discord
Powered by
# durable-objects
  • b

    brett

    05/07/2021, 6:40 PM
    what do you mean when you say lifetime?
  • b

    brett

    05/07/2021, 6:41 PM
    certainly possible, you could also use Workers KV from your durable object if necessary
  • a

    Adam Reed

    05/07/2021, 6:41 PM
    When is a DO disposed and how long can I keep it available?
  • b

    brett

    05/07/2021, 6:41 PM
    are you talking about the in-memory state then, and not persistent storage?
  • a

    Adam Reed

    05/07/2021, 6:41 PM
    I mean in persistent storage.
  • b

    brett

    05/07/2021, 6:42 PM
    that's durable storage that is never deleted (unless you delete it)
  • a

    Adam Reed

    05/07/2021, 6:42 PM
    Wouldn't you be concerned with users not disposing of them and them growing infinitely
  • a

    Adam Reed

    05/07/2021, 6:42 PM
    I didn't see charges for storage only requests.
  • a

    Adam Reed

    05/07/2021, 6:42 PM
    Seems like that could get out of hand.
  • d

    Deleted User

    05/07/2021, 6:42 PM
    that thought did enter my mind, just feels a bit hacky considering it's not the intended purpose of kv
  • d

    Deleted User

    05/07/2021, 6:43 PM
    not the intended purpose as in, using kv solely because it has higher storage limits
  • b

    brett

    05/07/2021, 6:43 PM
    there's prices for reads, writes, deletes and storage: https://blog.cloudflare.com/durable-objects-open-beta/
  • a

    Adam Reed

    05/07/2021, 6:43 PM
    I must have overlooked that. Thank you.
  • b

    brett

    05/07/2021, 6:43 PM
    but also we will offer ways for you to iterate your objects, so you can clean them up if need be
  • b

    brett

    05/07/2021, 6:43 PM
    so you could implement a TTL or something of your choosing
  • a

    Adam Reed

    05/07/2021, 6:44 PM
    Great!
  • t

    ttraenkler

    05/07/2021, 6:45 PM
    thanks for the info!
  • a

    Adam Reed

    05/07/2021, 6:45 PM
    The iteration would be big as it would allow us to clear up the DOs and log the results in a seperate cron worker vs having to have the DO handle its own disposal.
  • b

    brett

    05/07/2021, 6:45 PM
    that's fair, but KV is probably cheaper too, especially for larger objects. it may be a good fit unless you really need a transaction/consistent store
  • b

    brett

    05/07/2021, 6:46 PM
    yeah it's top of our mind right now
  • b

    brett

    05/07/2021, 6:46 PM
    something I should be working on as we speak 🙃
  • d

    Deleted User

    05/07/2021, 6:47 PM
    i mean... if you use DO as a sort of journaling system (?), it'd be consistent anyway right? or more like, if the DO is the only thing accessing it, it'll never be inconsistent since there's only one source of writes?
  • a

    Adam Reed

    05/07/2021, 6:47 PM
    We're using DOs as a session handler for our app, and the controller, for a voice product, very interesting to see how it's gonna work out.
  • a

    Adam Reed

    05/07/2021, 6:48 PM
    We also decided to use KV as a store for a voice recording, we were able to make a file store using it.
  • b

    brett

    05/07/2021, 6:48 PM
    that's (mostly) true. what I meant was if you need to do transactions across multiple keys, or things like that
  • a

    Adam Reed

    05/07/2021, 6:49 PM
    Big learning curve for us tho coming from dotnet and Azure Functions
  • d

    Deleted User

    05/07/2021, 6:50 PM
    hm.
  • d

    Deleted User

    05/07/2021, 6:51 PM
    i mean cheaper is nice and all, but half sure that'd come with a drastic increase in complexity which isn't exactly ideal
  • a

    Alex Braunreuther

    05/07/2021, 7:21 PM
    hey there, I was using the addEventhandler approach before switching to durable objects. Now I'm using the module based approach as I have to do when using DOs. It seams there is no location data on the request anymore - is this a problem on CF, intended or am I doing something wrong?
  • u

    Unsmart | Tech debt

    05/07/2021, 7:23 PM
    I think the best thing if you want to use KV as the actual data store you can add DO as a "middleman" to KV that will keep the data consistent. (I at least assume this would be the case). Basically on first request it would be: Req -> DO -> init from kv to memory -> update memory and kv -> end Then next requests would be: Req -> DO -> update memory and kv -> end Only potential problem I might see is whenever the DO gets evicted if another request comes in to re-instantiate the object and it reads an old value from KV.
1...798081...567Latest