/
brain.clj
54 lines (46 loc) · 1.11 KB
/
brain.clj
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
(ns jubot.brain
"Jubot brain manager."
(:require
[jubot.system :refer [system]]
[jubot.brain.memory :refer [map->MemoryBrain]]
[jubot.brain.redis :refer [map->RedisBrain]])
(:refer-clojure :exclude [set get keys]))
(defn create-brain
"Create the specified brain.
Params
config-option
:brain - A brain's name.
Return
Brain component.
"
[{:keys [brain] :as config-option}]
(case brain
"redis" (map->RedisBrain config-option)
(map->MemoryBrain config-option)))
(defn set
"Store data to system brain.
Before using this function, jubot.system should be started.
Params
k - Data key.
v - Data value.
"
[k v]
(some-> system :brain :set (as-> f (f k v))))
(defn get
"Get data from system brain.
Before using this function, jubot.system should be started.
Params
k - Data key.
Return
Stored data.
"
[k]
(some-> system :brain :get (as-> f (f k))))
(defn keys
"Get key list from system brain.
Before using this function, jubot.system should be started.
Return
Key list.
"
[]
(some-> system :brain :keys (as-> f (f))))