Skip to content

Instantly share code, notes, and snippets.

@reiddraper
Created December 18, 2012 22:19
Show Gist options
  • Save reiddraper/4332614 to your computer and use it in GitHub Desktop.
Save reiddraper/4332614 to your computer and use it in GitHub Desktop.
(require '[sumo.client :as sumo])
(require '[clojure.pprint :as pp])
;; make sure that allow_mult true is set on this bucket first
(def client (sumo/connect-pb))
;; make sure ping is working
(sumo/ping client)
;; true
;; put four conflicting values
(sumo/put client "sumo-test" "key" {:value "a"})
(sumo/put client "sumo-test" "key" {:value "b"})
(sumo/put client "sumo-test" "key" {:value "c"})
(sumo/put client "sumo-test" "key" {:value "d"})
;; now if we do a get, we'll see our 4 conflicting values
(def results (vec (sumo/get-raw client "sumo-test" "key")))
(pp/pprint results)
;; now we save the vclock
(def vclock (:vector-clock (nth results 0)))
;; remember the vclock is the same for all of these results
;; now when we overwrite the value, we'll include the vclock
(sumo/put client "sumo-test" "key" {:value "e" :vector-clock vclock})
;; now see that we've overwritten the value
(vec (sumo/get client "sumo-test" "key"))
;; notice now we just see the value 'e' instead of '[a, b, c, d]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment