示例#1
0
        public Task <IMutationResult> Insert <T>(string id, T content, Action <InsertOptions> optionsAction)
        {
            var options = new InsertOptions();

            optionsAction(options);

            return(Insert(id, content, options));
        }
示例#2
0
        public static Task <IMutationResult> InsertAsync <T>(this ICollection collection, string id, T content,
                                                             Action <InsertOptions> optionsAction)
        {
            var options = new InsertOptions();

            optionsAction(options);

            return(collection.InsertAsync(id, content, options));
        }
示例#3
0
        public Task <IMutationResult> Insert <T>(string id, T content, TimeSpan?timeout = null, TimeSpan expiration = default(TimeSpan),
                                                 ulong cas = 0, PersistTo persistTo = PersistTo.None, ReplicateTo replicateTo = ReplicateTo.None,
                                                 DurabilityLevel durabilityLevel = DurabilityLevel.None, CancellationToken token = default(CancellationToken))
        {
            var options = new InsertOptions
            {
                Timeout         = timeout,
                Expiration      = expiration,
                Cas             = cas, PersistTo = persistTo,
                ReplicateTo     = replicateTo,
                DurabilityLevel = durabilityLevel,
                Token           = token
            };

            return(Insert(id, content, options));
        }
示例#4
0
        public async Task <IMutationResult> Insert <T>(string id, T content, InsertOptions options)
        {
            var insertOp = new Add <T>
            {
                Key               = id,
                Content           = content,
                Cas               = options.Cas,
                Cid               = Cid,
                Expires           = options.Expiration.ToTtl(),
                DurabilityLevel   = options.DurabilityLevel,
                DurabilityTimeout = TimeSpan.FromMilliseconds(1500)
            };

            await ExecuteOp(insertOp, options.Token, options.Timeout).ConfigureAwait(false);

            return(new MutationResult(insertOp.Cas, null, insertOp.MutationToken));
        }