Created
June 12, 2011 18:24
-
-
Save manuel/1021846 to your computer and use it in GitHub Desktop.
Sample of EdgeLisp's content-based storage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; Sample of EdgeLisp's content-based storage system | |
;;; https://github.com/manuel/edgelisp/blob/master/client/base.lisp | |
;; Create a blob containing the file's contents. | |
(defvar test-blob (base-make-blob "Hello content-centric world!")) | |
#[base-blob Hello content-centric world!] | |
;; Create a tree with a directory entry named "hello.txt" pointing to the blob's ID (hash). | |
(defvar test-tree | |
(base-make-tree (list (base-make-dentry "hello.txt" (base-object-id test-blob))))) | |
#[base-tree [["hello.txt","9a402660cf165ae76a28e0c3c8d467f2ac2dcc55"]]] | |
;; Store blob and tree | |
(base-store test-blob) | |
9a402660cf165ae76a28e0c3c8d467f2ac2dcc55 | |
(base-store test-tree) | |
e610db547bc980a213186e237c30bb4be7c95d0d | |
;; Read blob and tree from storage (note that result is wrapped in option type ("Maybe")). | |
(base-read "e610db547bc980a213186e237c30bb4be7c95d0d") | |
#[some #[base-tree [["hello.txt","9a402660cf165ae76a28e0c3c8d467f2ac2dcc55"]]]] | |
(base-read "9a402660cf165ae76a28e0c3c8d467f2ac2dcc55") | |
#[some #[base-blob Hello content-centric world!]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment