zlacker

[parent] [thread] 4 comments
1. foepys+(OP)[view] [source] 2021-10-27 19:41:29
Redis has the INCR command that does this in redis without the additional round-trips (and race conditions). It also sets the value to 0 if the key doesn't exist.

So, I actually consider this to be exactly the bad behavior that people accuse Copilot of.

replies(2): >>gfosco+k3 >>speedg+y4
2. gfosco+k3[view] [source] 2021-10-27 19:56:41
>>foepys+(OP)
This was just one of its suggestions, but you're right of course.. it's all based on the training data and idioms used there. If it doesn't weight more modern code higher, if it's not aware of new versions and methods, it isn't going to be super intelligent.. but it can still give you some ideas.
3. speedg+y4[view] [source] 2021-10-27 20:03:32
>>foepys+(OP)
Yes it's not very shinning there. I would also throw the error instead of printing the error to the console and returning undefined.
replies(1): >>ponyou+bq
◧◩
4. ponyou+bq[view] [source] [discussion] 2021-10-27 22:12:08
>>speedg+y4
You are in a callback there. Goodbye your error!
replies(1): >>speedg+sn1
◧◩◪
5. speedg+sn1[view] [source] [discussion] 2021-10-28 07:34:25
>>ponyou+bq
Oh right. I once made a layer on top of the redis client to use promises because callbacks are a pain to deal with.
[go to top]