from Hacker News

Show HN: A LRU cache using go generics

by _256 on 1/12/22, 1:13 PM with 11 comments

  • by _256 on 1/12/22, 1:14 PM

    This is a simple LRU cache I made to get my hands on generics which is available in the go 1.18 beta. Feedback is welcome :-)
  • by morelisp on 1/13/22, 8:54 PM

    > Feedback is welcome

    You'll probably be a lot better off a) preallocating the elements so your memory is nicely contiguous, b) tracking indices and not pointers. If I wanted to pay 24b overhead per item I'd use an `interface{}`. :)