Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

One thing I am not sure, maybe I missed something in the blog but will there be always one instance of this object or can there be multiple?


Durable Objects are globally unique, so it's guaranteed that there's just one instance with a given id.


Right, that's what I got from the Unique explanation in the doc. What I am confused about is this part:

With Durable Objects, you instead design your storage model to match your application's logical data model. For example, a document editor would have an object for each document, while a chat app would have an object for each chat. There is no problem creating millions or billions of objects, as each object has minimal overhead.

What does it mean that a document editor will have an object for each document? Will I have to create a new UDO each time a new document is created?


It means that you'd use a different ID to access each document. Each document's Durable Object would run the same code as part of the same namespace of Durable Objects, but have their own in-memory and durable state. Check out the docs for a bit more context: https://developers.cloudflare.com/workers/learning/using-dur...


I am still a bit confused. Will this ID be different from the object id of for accessing the Durable Object, essentially in this case we would be using the Durable Object as a key-value storage? Or is it like the Namespace is separate from the Durable Object and each Namespace can have multiple objects of the same class under?

Edit: I think I get it now. Sorry I misunderstood that each Durable Object is like a singleton for the class you define. Its the other way around, you have the definition and namespace and then you can create a new object from those whenever you need it and this one would unique and accessible across all workers.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: