Ejemplo n.º 1
0
        public ulong DecrementMyCounter(string reportName, ILambdaContext context)
        {
            ulong index = memcachedClient.Decrement($"{reportName}_GP_Count", 0, 1, this.expiration);

            context.Logger.Log($"DecrementMyCounter {index}");
            if (index == 0)
            {
                context.Logger.Log($"DecrementMyCounter Removed index == 0");
                memcachedClient.Remove($"{reportName}_GP_Count");
            }
            return(index);
        }
Ejemplo n.º 2
0
        public IActionResult Decrement(string key, [FromBody] IncrDecrCacheItem item)
        {
            if (item == null)
            {
                item = new IncrDecrCacheItem();
            }

            if (!item.Cas.HasValue || item.Cas.Value == 0)
            {
                ulong result;
                if (item.ValidFor.HasValue)
                {
                    result = _memcachedClient.Decrement(key, item.DefaultValue.Value, item.Delta.Value, item.ValidFor.Value);
                }
                else if (item.ExpireAt.HasValue)
                {
                    result = _memcachedClient.Decrement(key, item.DefaultValue.Value, item.Delta.Value, item.ExpireAt.Value);
                }
                else
                {
                    result = _memcachedClient.Decrement(key, item.DefaultValue.Value, item.Delta.Value);
                }

                return(Ok(result));
            }
            else
            {
                CasResult <ulong> value = new CasResult <ulong>();

                if (item.ValidFor.HasValue)
                {
                    value = _memcachedClient.Decrement(key, item.DefaultValue.Value, item.Delta.Value, item.ValidFor.Value, item.Cas.Value);
                }
                else if (item.ExpireAt.HasValue)
                {
                    value = _memcachedClient.Decrement(key, item.DefaultValue.Value, item.Delta.Value, item.ExpireAt.Value, item.Cas.Value);
                }
                else
                {
                    value = _memcachedClient.Decrement(key, item.DefaultValue.Value, item.Delta.Value, item.Cas.Value);
                }

                var result = new { value = value.Result, cas = value.Cas, statusCode = value.StatusCode };

                return(Ok(result));
            }
        }
Ejemplo n.º 3
0
 public ulong Decrement(string key, ulong defaultValue, ulong delta)
 {
     return(_memcachedClient.Decrement(key, defaultValue, delta));
 }