Ejemplo n.º 1
0
        private async Task ExecuteSetExpr(SetExpr expr)
        {
            var key = new ORSetKey <string>(expr.Key);

            try
            {
                var set = await ddata.GetAsync(key) ?? ORSet <string> .Empty;

                switch (expr.Symbol)
                {
                case Symbol.ADD: set = set.Add(cluster, expr.Value); break;

                case Symbol.REM: set = set.Remove(cluster, expr.Value); break;

                default: throw new NotSupportedException($"Operation {expr.Symbol} not supported on ORSet");
                }

                await ddata.UpdateAsync(key, set, writeConsistency);

                var value = await ddata.GetAsync(key);

                Console.WriteLine($"Updated '{key}': {value}");
            }
            catch (Exception e)
            {
                Console.WriteLine($"Couldn't perform UPDATE for {key}: {e}");
            }
        }