Skip to content

Instantly share code, notes, and snippets.

@afeinberg
Created July 10, 2010 06:25
Show Gist options
  • Select an option

  • Save afeinberg/470494 to your computer and use it in GitHub Desktop.

Select an option

Save afeinberg/470494 to your computer and use it in GitHub Desktop.
(def *factory* (voldemort/store-client-factory
["tcp://localhost:6666"]))
(def *client-person* (.getStoreClient *factory* "person"))
(def *client-zipcode* (.getStoreClient *factory* "zipcode"))
(defn hello-voldemort []
(.put *client-person* "alex.feinberg" { "first" "alex",
"last" "feinberg",
"zipcode" 94041 })
(.put *client-zipcode* (get (.getValue (.get *client-person* "alex.feinberg"))
"zipcode")
["alex.feinberg"])
(.put *client-person* "bradford.cross" { "first" "bradford",
"last" "cross",
"zipcode" 94041 })
(voldemort/apply-update
*client-zipcode*
(fn [client]
(let [obj (.get client 94041)
val (.getValue obj)]
(.put client 94041
(doto obj
(.setObject (cons
"bradford.cross"
val)))))))
(doseq [[_ person-versioned] (.getAll *client-person*
(.getValue (.get *client-zipcode*
94041)))]
(println (get (.getValue person-versioned)
"first")
"lives in 94041")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment