Re:Adding view count and like button to 11ty
by bastawhiz on Sunday June 23, 2024 @08:46PM
(#40771849)
The HSET calls are not just unnecessary, they're a bug. It introduces the possibility of a race condition where a view or like happens between the HGET and HSET. HSETing the values to zero doesn't actually make anything faster or more correct, it just introduces the possibility of overwriting a value that came in moments ago.
[ Parent
| on HN ]
Re:Adding view count and like button to 11ty
by chilling on Sunday June 23, 2024 @11:15PM
(#40772431)
so how would you approach this?
Re:Adding view count and like button to 11ty
by porridgeraisin on Monday June 24, 2024 @12:36AM
(#40772691)
Just do hincrby alone, if it doesn't exist it will automatically become 1