karlseguin / ccache

A golang LRU Cache for high concurrency
MIT License
1.31k stars 121 forks source link

perf: add setnx2 #93

Closed chenyijun266846 closed 1 month ago

chenyijun266846 commented 1 month ago
  1. add setnx2 to bucket, the differents from setnx are:
    • init newItem after double check
    • use func instead of value to reduce init cost of value
    • return existing
  2. add setnx2 to cache, the differents from setnx are:
    • return *Item[T]
    • handle promotables
karlseguin commented 1 month ago

thanks