https://discord.cloudflare.com logo
Join Discord
Powered by
# r2
  • a

    aydyn

    05/11/2023, 4:37 AM
    idk, a counter api ig?
  • a

    aydyn

    05/11/2023, 4:38 AM
    to be clear i mean an api where a user could hit or get an id to get a count
  • a

    aydyn

    05/11/2023, 4:39 AM
    i was thinking kv but i wasn’t sure if that would propagate globally fast enough
  • c

    Chaika

    05/11/2023, 4:40 AM
    If it was a counter you want to increment, Durable Object Storage. R2 is also strongly consistent but pretty overkill. If it was something like a website counter, you could write to a durable object, which stores locally and also writes to KV, which you could read and have cached as long as if you're fine with the result not being consistent
  • c

    Chaika

    05/11/2023, 4:41 AM
    KV is eventually consistent and limited on writes, so you wouldn't want to use it alone (at least for that use case, ex: if you tried to read and then update the counter from KV in two colos at once, you lose one of them)
  • a

    aydyn

    05/11/2023, 4:42 AM
    thank you for such helpful insight :)
  • a

    aydyn

    05/11/2023, 4:43 AM
    yup that was what i took into consideration and was trying to choose something other than kv
  • a

    aydyn

    05/11/2023, 4:46 AM
    i got another question similar to the previous one and it’s pretty complex/off topic, mind if i ask u in dms?
  • m

    meowzilla

    05/11/2023, 4:48 AM
    counting would be very ideal with #981314061268578304 if all you’re doing is “adding”
  • c

    Chaika

    05/11/2023, 4:50 AM
    If it's something workers related/non-private could ask in #1052656806058528849 post and other people can potentially benefit from it, otherwise sure
  • a

    aydyn

    05/11/2023, 4:50 AM
    hm how so? also ideally i’d like to have add and subtract and some other stuff, so it won’t be strictly ++
  • m

    meowzilla

    05/11/2023, 4:51 AM
    yeah then probably DO would be best. I was just thinking how cheap it could be if you were just incrementing a count with AE
  • m

    meowzilla

    05/11/2023, 4:52 AM
    but Chaika is right, DO and a mix of KV would be nice
  • c

    Chaika

    05/11/2023, 4:53 AM
    Analytics Engine is great for writing append-only statistics / billing / etc, the workers binding is easy to use, but if you need more control / the data to never be sampled, then would need to use something else
  • a

    AlHill

    05/11/2023, 9:07 AM
    Can workers copy or move files of R2? I can't see it in reference https://developers.cloudflare.com/r2/api/workers/workers-api-reference/#bucket-method-definitions
  • k

    Karew

    05/11/2023, 9:14 AM
    I am not sure why copyObject is missing there, but there is no concept of moving on R2 (or S3), you would do a copy and then delete the original
  • k

    Karew

    05/11/2023, 9:15 AM
    And if they had copyObject it would be pretty speedy because the server would do it intra-server and not pass the file through your worker
  • a

    AlHill

    05/11/2023, 9:16 AM
    I know there's no move or rename in S3, but I cannot find copy in the docs neither
  • k

    Karew

    05/11/2023, 9:16 AM
    Yeah it's supported but I am not sure why the Worker API doesn't have it
  • a

    AlHill

    05/11/2023, 9:18 AM
    I tried a naive
    bucket.copy(from, to)
    just in case someone forgot to put it in the docs, but no, haha
  • a

    AlHill

    05/11/2023, 9:20 AM
    I tested
    Copy code
    const got = await bucket.get(from)
    await bucket.put(to, got.body)
    await bucket.delete(from)
    and works fine, can it have problems with big files?
  • k

    Karew

    05/11/2023, 9:22 AM
    That works but it's not great because the file passes through your worker, yeah
  • h

    HardAtWork

    05/11/2023, 9:40 AM
    It should be fine if your files are less than a few gigs
  • h

    HardAtWork

    05/11/2023, 9:40 AM
    Theoretically, it should be able to handle any file in R2, but it gets more unreliable the larger it is...
  • a

    AlHill

    05/11/2023, 9:43 AM
    And execution times, limits and all that stuff could be a problem?
  • m

    modrin

    05/11/2023, 9:45 AM
    I mean, egress is free.. but we've pushed 100TB ea. for three months via R2 via CF CDN and received a "letter of invitation" to discuss moving onto Enterprise 😁 So I would say it's technically free, up until some point
  • h

    HardAtWork

    05/11/2023, 9:46 AM
    Not really. If you are just streaming, it doesn't count toward any limits, other than the 30 second minimum runtime cap.
  • h

    HardAtWork

    05/11/2023, 9:47 AM
    All limits are * with "Hey, you might be Enterprise level. Maybe you should upgrade?" It all just depends on how much you use.
  • m

    modrin

    05/11/2023, 9:50 AM
    When Business is 200 and Ent is 5K it's a little steep. But we understand it 🙂
  • s

    Slush

    05/11/2023, 9:52 AM
    Then I'm fuqed O.o
1...101710181019...1050Latest