https://discord.cloudflare.com logo
Join Discord
Channels
general-help
analytics-engine-beta
browser-rendering-api-beta
cloudflare-for-saas
cloudflare-go
coding-help
constellation
d1-open-alpha
do-alarms
durable-objects
email-routing
frameworks
functions
general-discussions
general-faq
images
⚡instant-logs
👋intros
kv
logs-engine
love
magic-network-monitoring
miniflare
pages-discussions
pages-feature-suggestions
pages-help
pages-plugins
pubsub-beta
queues-beta
r2
radar
service-bindings
starboard
stream
terraform-provider-cloudflare
🤖turnstile-beta
web3
web-research
welcome-and-rules
what-i-built
wildebeest
workerd
workers-discussions
workers-feature-suggestions
workers-for-platforms
workers-help
workers-libraries
🦀workers-rs
wrangler
zaraz
Powered by
# durable-objects
  • h

    HardAtWork

    03/29/2023, 9:25 AM
    It can’t store functions, but it should be able to store numbers, strings, objects, ArrayBuffers(I think), etc.
  • c

    Crazy Rabbit

    03/29/2023, 9:26 AM
    thanks
  • c

    Crazy Rabbit

    03/29/2023, 9:26 AM
    so .get function will return the same variable type
  • c

    Crazy Rabbit

    03/29/2023, 9:26 AM
    the same as it has been stored
  • h

    HardAtWork

    03/29/2023, 9:27 AM
    Yup, as long as it is compatible with the serializer, it will return the same value
  • c

    Crazy Rabbit

    03/29/2023, 9:28 AM
    thanks
  • c

    Crazy Rabbit

    03/29/2023, 9:38 AM
    It's possible to auto clean unused variables similar as KV.
  • c

    Crazy Rabbit

    03/29/2023, 9:38 AM
    Like TTL
  • c

    Crazy Rabbit

    03/29/2023, 9:38 AM
    So every variable older than a day will get auto deleted
  • h

    HardAtWork

    03/29/2023, 9:39 AM
    No, but you could probably use Alarms to do something like that
  • c

    Crazy Rabbit

    03/29/2023, 9:40 AM
    any examples of Alarms?
  • h

    HardAtWork

    03/29/2023, 9:43 AM
    https://letmegooglethat.com/?q=Durable+Object+Alarms
  • c

    Crazy Rabbit

    03/29/2023, 9:44 AM
    The key already contains a datetime in milliseconds as value. So I would just need to loop thru all the keys / check it's value (datetime) and delete them if they contain datetime older than X milliseconds.
  • c

    Crazy Rabbit

    03/29/2023, 9:44 AM
    Thanks
  • c

    Crazy Rabbit

    03/29/2023, 9:45 AM
    also not my fault that examples of Alarms are missing from docs XD
  • h

    HardAtWork

    03/29/2023, 9:46 AM
    https://developers.cloudflare.com/workers/learning/using-durable-objects/#alarms-in-durable-objects
  • c

    Crazy Rabbit

    03/29/2023, 9:47 AM
    no examples
  • c

    Crazy Rabbit

    03/29/2023, 9:51 AM
    So basically instead of having one alarm that will check all keys to determine which ones are old enough to be deleted, I should create new alarm on every key that is inserted
  • c

    Crazy Rabbit

    03/29/2023, 9:53 AM
    wait there can only be on alarm per DO
  • d

    Dani Foldi

    03/29/2023, 9:58 AM
    you can use
    do-taskmanager
    for that
  • c

    Crazy Rabbit

    03/29/2023, 10:00 AM
    Will probably just set the alarm for first day in the upcoming month and delete everything.
  • c

    Crazy Rabbit

    03/29/2023, 10:00 AM
    so people would be able to vote twice in the same day on the first day of the month, but this shouldn't be the problem.
  • d

    Dani Foldi

    03/29/2023, 10:01 AM
    I have no context for what voting this is, but there 100% is a way to guarantee that there can only be one vote for a month(?)
  • c

    Crazy Rabbit

    03/29/2023, 10:02 AM
    https://discordapp.com/channels/595317990191398933/874727019479437372/1090384086243217468
  • c

    Crazy Rabbit

    03/29/2023, 10:02 AM
    one vote per day for each poll limited with username and also IP.
  • d

    Dani Foldi

    03/29/2023, 10:03 AM
    and you're using one DO for each poll?
  • c

    Crazy Rabbit

    03/29/2023, 10:03 AM
    Correct
  • h

    HardAtWork

    03/29/2023, 10:04 AM
    Can’t you just do this once an hour?
  • d

    Dani Foldi

    03/29/2023, 10:04 AM
    if you use UTC timestamps, you can safely compare between current & submitted times
  • c

    Crazy Rabbit

    03/29/2023, 10:05 AM
1...527528529...567Latest