public void Append(string key, string value) { BeginOperation(); //This could be done far more efficiently and atomically with a sproc using (IKeyLock keyLock = GetKeyLock(lockPrefix + key, DateTime.UtcNow.AddSeconds(10), new SimpleLockRetryStrategy(5, 500))) { var existingValue = Get(key); Set(key, existingValue + value); } }
public ulong GetNextSequenceValue(string key, int increment) { BeginOperation(); //set up a sproc for this using (IKeyLock keyLock = GetKeyLock(lockPrefix + key, DateTime.UtcNow.AddSeconds(10), new SimpleLockRetryStrategy(5, 500))) { ulong value = 0; var valueRaw = Get(key); if (valueRaw != string.Empty) { value = (ulong)int.Parse(valueRaw); } value = value + (ulong)increment; Set(key, value.ToString()); return(value); } }