public ulong GetNextSequenceValue(string key, int increment) { lock (_memoryBackingStore.GetLockObject()) { var Val = _memoryBackingStore[key]; if (Val == null) { Val = new MemoryStorageRow() { Value = "0" } } ; ulong sequence = 0; ulong.TryParse(Val.Value, out sequence); sequence = sequence + (ulong)increment; Val.Value = sequence.ToString(); Val.Cas = GenerateCas(); _memoryBackingStore[key] = Val; return(sequence); } }
public void Set(string key, string value, TimeSpan expiresIn) { lock (_memoryBackingStore.GetLockObject()) { _memoryBackingStore[key] = new MemoryStorageRow() { Value = value, Cas = GenerateCas(), Expiry = DateTime.UtcNow + expiresIn }; } }
public void Set(string key, string value, DateTime expires) { lock (_memoryBackingStore.GetLockObject()) { _memoryBackingStore[key] = new MemoryStorageRow() { Value = value, Cas = GenerateCas(), Expiry = expires }; } }
public void Set(string key, string value) { lock (_memoryBackingStore.GetLockObject()) { _memoryBackingStore[key] = new MemoryStorageRow() { Value = value, Cas = GenerateCas() }; } }
public void Set(string key, string value, ulong cas) { lock (_memoryBackingStore.GetLockObject()) { if (_memoryBackingStore[key].Cas != cas) { throw new CASException(); } _memoryBackingStore[key] = new MemoryStorageRow() { Value = value, Cas = GenerateCas() }; } }
public void Set(string key, string value, ulong cas, TimeSpan expiresIn) { lock (_memoryBackingStore.GetLockObject()) { if (_memoryBackingStore[key].Cas != cas) { throw new CASException(); } _memoryBackingStore[key] = new MemoryStorageRow() { Value = value, Cas = GenerateCas(), Expiry = DateTime.UtcNow + expiresIn }; } }
public void Append(string key, string value) { lock (_memoryBackingStore.GetLockObject()) { var Val = _memoryBackingStore[key]; if (Val == null) { Val = new MemoryStorageRow() { Value = string.Empty } } ; Val.Value = Val.Value + value; _memoryBackingStore[key] = Val; } }