Example #1
0
        public Task <IMutationResult> Upsert <T>(string id, T content, Action <UpsertOptions> configureOptions)
        {
            var options = new UpsertOptions();

            configureOptions(options);

            return(Upsert(id, content, options));
        }
Example #2
0
        public static Task <IMutationResult> UpsertAsync <T>(this ICollection collection, string id, T content,
                                                             Action <UpsertOptions> configureOptions)
        {
            var options = new UpsertOptions();

            configureOptions(options);

            return(collection.UpsertAsync(id, content, options));
        }
Example #3
0
        public Task <IMutationResult> Upsert <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 UpsertOptions
            {
                Timeout         = timeout,
                Expiration      = expiration,
                Cas             = cas, PersistTo = persistTo,
                ReplicateTo     = replicateTo,
                DurabilityLevel = durabilityLevel,
                Token           = token
            };

            return(Upsert(id, content, options));
        }
Example #4
0
        public async Task <IMutationResult> Upsert <T>(string id, T content, UpsertOptions options)
        {
            var upsertOp = new Set <T>
            {
                Key               = id,
                Content           = content,
                Cas               = options.Cas,
                Cid               = Cid,
                Expires           = options.Expiration.ToTtl(),
                DurabilityLevel   = options.DurabilityLevel,
                DurabilityTimeout = TimeSpan.FromMilliseconds(1500)
            };

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

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