bryan maass

bcm@bryans-MBP.gateway

Rethinkdb and Clojure

Bryan Maass

Blog escherize.com
Clojurians Slack escherize
Twitter @escherize
Telegram @escherize

Rethinkdb?

RethinkDB is an open source, scalable database that makes building (realtime) apps dramatically easier.

It uses a reactive paradigm which allows it to push updates to clients(!).

Query structure based on S-expressions.

No SQL database.

"Works great" - Jepsen

Excellent ops interface (programatic + web-based)

Call me Maybe

Call me Maybe (Jepsen) Results: "As far as I can ascertain, RethinkDB’s safety claims are accurate. You can lose updates if you write with anything less than majority, and see assorted read anomalies with single or outdated reads, but majority/majority appears linearizable." - aphyr

one.love

http://z.caudate.me/one-love-an-inspired-rethink/ https://github.com/zcaudate/one.love by Chris Zhang

  • Uses awesome (mostly) data-first query dsl
  • Uses the official Java Client.

one.love - Connecting:

(use 'one.love)
(def conn (connect {:host "localhost"
                    :port 28015}))

one.love - Create a table:

(run conn
    [[:db "test"]
     [:table-create "movies"]])

one.love - Import a table from json over http:

(run conn
      [[:table "movies"]
       [:insert [:http "http://rethinkdb.com/sample/top-250-ratings.json"]]])

one.love - Query for the top movie:

(run conn
  [[:table "movies"]
   [:without "id"]
   [:filter {:rank 1}]])
;;=> [{:title "The Shawshank Redemption"
;;     :year 1994,
;;     :rating 9.2,
;;     :rank 1,
;;     :votes 1262930,}]

clj-rethinkdb

https://github.com/apa512/clj-rethinkdb Erik Strömberg

Uses the http api, and a function-based interface.

Demo Repo:

https://github.com/escherize/rethinkdb_overview

Created by Bryan Maass