public void IncrementPlusCodeData(string plusCode, string key, double changeAmount, double?expirationTimer = null) { if (!DataCheck.IsInBounds(cache.Get <IPreparedGeometry>("serverBounds"), OpenLocationCode.DecodeValid(plusCode))) { return; } PerformanceTracker pt = new PerformanceTracker("IncrementPlusCodeData"); string lockKey = plusCode + key; locks.TryAdd(lockKey, new ReaderWriterLockSlim()); var thisLock = locks[lockKey]; thisLock.EnterWriteLock(); var data = GenericData.GetAreaData(plusCode, key); double val = 0; Double.TryParse(data.ToString(), out val); val += changeAmount; GenericData.SetAreaData(plusCode, key, val.ToString(), expirationTimer); thisLock.ExitWriteLock(); if (thisLock.WaitingWriteCount == 0) { locks.TryRemove(lockKey, out thisLock); } pt.Stop(); }
public bool SetPlusCodeData(string plusCode, string key, string value, double?expiresIn = null) { if (!DataCheck.IsInBounds(cache.Get <IPreparedGeometry>("serverBounds"), OpenLocationCode.DecodeValid(plusCode))) { return(false); } return(GenericData.SetAreaData(plusCode, key, value, expiresIn)); }