Exemple #1
0
        public T Get <T>(string key)
        {
            var bucket   = Configuration.GetBucketForType <T>();
            var document = Get <T>(bucket.BucketName, key, bucket.QuorumReadNodes);

            VectorClockLookup.SetVectorFor(key, document.VectorClock);
            return(document.Value);
        }
Exemple #2
0
        public bool Persist <T>(string key, T instance)
        {
            var bucket      = Configuration.GetBucketForType <T>();
            var vectorClock = VectorClockLookup.GetVectorFor(key);
            var document    = new Document <T>(instance, vectorClock);

            return(Persist(
                       bucket.BucketName,
                       key,
                       vectorClock,
                       document,
                       bucket.QuorumWriteNodes, bucket.QuorumWriteNodes));
        }
Exemple #3
0
        public bool Persist <T>(string bucket, string key, string vectorClock, Document <T> document, uint writeQuorum,
                                uint minimumWrites)
        {
            var riakContent = new RiakContent(document.Value.ToProtocolBuffer(), document.ContentType, document.Charset,
                                              document.ContentEncoding, document.VectorClock, document.LastModified,
                                              document.LastModifiedInSeconds);
            var command = vectorClock == null
                              ? CommandFactory.CreatePersistNew(bucket, key, riakContent, writeQuorum, minimumWrites,
                                                                true)
                              : CommandFactory.CreatePersistExisting(bucket, key, vectorClock, riakContent, writeQuorum,
                                                                     minimumWrites, true);

            Persisted result;
            var       success = (result = command.Execute()) != null;

            if (success)
            {
                VectorClockLookup.SetVectorFor(key, ByteExtensions.FromBytes(result.VectorClock));
            }
            return(success);
        }