Skip to content

9. Asami 2

Paula Gearon edited this page Jun 30, 2021 · 1 revision

Asami 2 includes a Durable storage system. This is enabled with the URIs that use the scheme asami:local

For instance:

(require '[asami.core :as d])

;; Create an in-memory database, named dbname
(def db-uri "asami:local://dbname")
(d/create-database db-uri)

;; Create a connection to the database
(def conn (d/connect db-uri))

;; Data can be loaded into a database either as objects, or "add" statements:
(def first-movies [{:movie/title "Explorers"
                    :movie/genre "adventure/comedy/family"
                    :movie/release-year 1985}
                   {:movie/title "Demolition Man"
                    :movie/genre "action/sci-fi/thriller"
                    :movie/release-year 1993}
                   {:movie/title "Johnny Mnemonic"
                    :movie/genre "cyber-punk/action"
                    :movie/release-year 1995}
                   {:movie/title "Toy Story"
                    :movie/genre "animation/adventure"
                    :movie/release-year 1995}])

@(d/transact conn {:tx-data first-movies})

The index files reserve additional space while they are open. This space will be freed up when the connection is released:

(d/release conn)
Clone this wiki locally