コード例 #1
0
        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);
            }
        }
コード例 #2
0
 public void Set(string key, string value, TimeSpan expiresIn)
 {
     lock (_memoryBackingStore.GetLockObject())
     {
         _memoryBackingStore[key] = new MemoryStorageRow()
         {
             Value = value, Cas = GenerateCas(), Expiry = DateTime.UtcNow + expiresIn
         };
     }
 }
コード例 #3
0
 public void Set(string key, string value, DateTime expires)
 {
     lock (_memoryBackingStore.GetLockObject())
     {
         _memoryBackingStore[key] = new MemoryStorageRow()
         {
             Value = value, Cas = GenerateCas(), Expiry = expires
         };
     }
 }
コード例 #4
0
 public void Set(string key, string value)
 {
     lock (_memoryBackingStore.GetLockObject())
     {
         _memoryBackingStore[key] = new MemoryStorageRow()
         {
             Value = value, Cas = GenerateCas()
         };
     }
 }
コード例 #5
0
        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()
                };
            }
        }
コード例 #6
0
        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
                };
            }
        }
コード例 #7
0
        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;
            }
        }