Build a URL shortener with Go and Chi like TINYURL

Поделиться
HTML-код
  • Опубликовано: 24 ноя 2024

Комментарии • 9

  • @gjrivero
    @gjrivero 9 месяцев назад +1

    Excellent example and clear didactics about the topic

  • @ErrolVas
    @ErrolVas 9 месяцев назад +1

    Please do the complete video on system design. Thank you.

  • @LydiaOnohi
    @LydiaOnohi 6 месяцев назад +1

    Please do the complete video on systems design

  • @michelsmith6835
    @michelsmith6835 6 дней назад

    on inserting to the map, why locking is needed if the key is different for each request? is locking necessary even if the insertion is to different keys?

    • @practicego
      @practicego  2 дня назад

      It's a good question. I didn't know the answer.
      This is what I found
      Why Locking is Necessary, Even for Different Keys:
      While it might seem counterintuitive that locking is necessary when inserting into a map with different keys, the underlying implementation of Go maps can cause issues in concurrent scenarios:
      * Hash Collisions:
      * Multiple keys can hash to the same index within the map's internal hash table.
      * When multiple goroutines try to insert into the same bucket, data races can occur, potentially leading to incorrect values or even map corruption.
      * Resize Operations:
      * If the map's capacity is exceeded, a resize operation is triggered.
      * During a resize, the map's internal structure is reallocated and rehashed.
      * Concurrent access to the map during a resize can lead to data loss or incorrect behavior.

    • @michelsmith6835
      @michelsmith6835 2 дня назад

      @@practicego thank you for sharing! I kind of see why but I would prefer some visual explanation of how things happen in memory. will look more into this when I have some time. thank you.

  • @prashlovessamosa
    @prashlovessamosa 9 месяцев назад +1

    Thanks.