Hello, if there’s a map with key-value pair like (IP string, data struct{knowledge string}
) and I have to regularly replace the knowledge
for every IP and now and again I additionally want so as to add/take away IPs, so what’s the higher approach for the concurrent management for the replace of that Map besides the RWLock? as a result of for RWLock it is going to lock the entire map for every IP knowledge replace, thanks!
Perhaps use sync.Map(sync package deal – sync – Go Packages).
sync.Map takes care of all that locking (or atomic operations) for you—so no guide locking wanted
It is likely to be overkill, however you would use an in-memory caching answer comparable to:
You can additionally possibly take inspiration from their weblog put up about constructing it: