Datahike storage is built on top of konserve, a universal key-value store abstraction. To add a new storage backend to Datahike, you simply implement a konserve backend. Once your konserve backend is required and registered, Datahike will transparently work on top of it.
That's it! Datahike will automatically work with any konserve backend.
See the konserve documentation for:
While konserve backends work out of the box with Datahike, you can optionally add Datahike-specific optimizations:
For performance optimization, you can add custom serialization handlers for Datahike's data structures. See datahike-lmdb as an example, which installs LMDB-specific Datahike serialization handlers.
Datahike ships with built-in support for:
:memory - In-memory storage (via konserve):file - File-based storage (via konserve)Additional backends available through konserve:
Once your konserve backend is available, use it with Datahike by specifying the backend keyword:
(require '[datahike.api :as d])
;; Example: using a custom backend
(def cfg {:store {:backend :your-backend-keyword
:id #uuid "550e8400-e29b-41d4-a716-446655440000"
;; ... backend-specific configuration
}})
(d/create-database cfg)
(def conn (d/connect cfg))
While less common than implementing backends, you can also implement custom index data structures for Datahike. This allows exploring different index algorithms optimized for specific use cases.
Datahike uses persistent-set as the default index. The hitchhiker-tree index (:datahike.index/hitchhiker-tree) is available for backwards compatibility and can be useful for certain workloads.
To implement a custom index:
src/datahike/index/):index :your-index-keyword in the database configurationExample configuration with custom index:
(def cfg {:store {:backend :memory
:id #uuid "550e8400-e29b-41d4-a716-446655440000"}
:index :datahike.index/hitchhiker-tree ; or your custom index
:schema-flexibility :write})
This is an advanced topic primarily useful for research or highly specialized performance requirements.
Can you improve this documentation? These fine people already did:
Judith, Christian Weilbach, Timo Kramer & Konrad KühneEdit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |