-
Notifications
You must be signed in to change notification settings - Fork 29
/
xach-test.lisp
55 lines (44 loc) · 1.04 KB
/
xach-test.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
(cl:defpackage #:xach-test
(:use #:graph-db #:cl))
(in-package #:xach-test)
(def-vertex photo ()
(title
description
date-taken)
:photodb)
(def-vertex album ()
(title
description
date-created)
:photodb)
(def-edge has-photo ()
()
:photodb)
(def-vertex user ()
(name)
:photodb)
(def-edge bought-photo ()
(price)
:photodb)
(defun load-views ()
(def-view title (photo :photodb)
(:map
(lambda (photo)
(when (title photo)
(yield (title photo) nil))))))
(defun pmod-test (photo new-title)
(let ((copy (copy photo)))
(setf (title copy) new-title)
(save copy)))
(defun conflict-test (id new-title delay &key thread)
(let ((thunk
(lambda ()
(with-transaction ()
(pmod-test (lookup-photo id) new-title)
(sleep delay)))))
(if thread
(sb-thread:make-thread thunk)
(funcall thunk))))
(defmethod print-object ((photo photo) stream)
(print-unreadable-object (photo stream :type t :identity t)
(format stream "~S" (title photo))))