kenton
04/22/2021, 7:03 PMidFromName()
always returns instantly. It computes the ID using an algorithm. There's no need to do any network I/O. So there's no performance difference between using idFromName()
vs. idFromString()
(which takes the raw hex ID). With all that said, newUniqueId()
produces IDs that are faster to look up than those produced by idFromName()
.kenton
04/22/2021, 7:04 PMidFromName()
needs to check whether the same name is used anywhere else in the world. newUniqueId()
doesn't need to do any such check because it knows what it returns is unique.)vans163
04/22/2021, 8:12 PMvans163
04/22/2021, 8:12 PMkenton
04/22/2021, 8:13 PMkenton
04/22/2021, 8:13 PMvans163
04/22/2021, 8:13 PMvans163
04/22/2021, 8:14 PMkenton
04/22/2021, 8:14 PMkenton
04/22/2021, 8:15 PMidFromName()
vs. one created using newUniqueId()
vans163
04/22/2021, 8:16 PMkenton
04/22/2021, 8:18 PMvans163
04/22/2021, 8:19 PMjavascript
let id = env.USER.idFromName("username:bob")
let obj = env.USER.get(id)
return obj.fetch(request.url, init);
// inside USER bob DO
internal_id = state.id.toString()
let id = env.RING.idFromName("north_america")
let obj = env.RING.get(id)
return obj.fetch(request.url, {internal_id: internal_id});
// inside RING do
env.USER.idFromString(internal_id_we_got_from_USER)
..
vans163
04/22/2021, 8:19 PMvans163
04/22/2021, 8:20 PMkenton
04/22/2021, 8:22 PMenv.USER.idFromName("username:bob")
will always return exactly the same value forever, regardless of whether the object is running or even exists.vans163
04/22/2021, 8:22 PMkenton
04/22/2021, 8:22 PMkenton
04/22/2021, 8:22 PMvans163
04/22/2021, 8:23 PMkenton
04/22/2021, 8:23 PMtoString()
itvans163
04/22/2021, 8:23 PMkenton
04/22/2021, 8:23 PMidFromString(stringifiedId)
to parse itvans163
04/22/2021, 8:24 PMvans163
04/22/2021, 8:24 PMkenton
04/22/2021, 8:24 PMvans163
04/22/2021, 8:25 PMmolmorg
04/22/2021, 10:29 PM./index.mjs
but I played I added ./dist to test if that was the cause but no. I just got it working... by adding the --new-class LogTopic
switch.... that's a pretty misleading error - sure it used to be different and more specific if you didn't have that switch and hadn't previously deployed the class.Deleted User
04/23/2021, 1:40 AMDeleted User
04/23/2021, 1:40 AM