-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The transaction cache holds transaction data that currently only consists of the instant at which the transaction happened. Transaction data is keyed by t.
- Loading branch information
1 parent
e60b84e
commit 1bbef6f
Showing
22 changed files
with
285 additions
and
65 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(ns blaze.db.resource-handle-cache.spec | ||
(:require | ||
[clojure.spec.alpha :as s])) | ||
|
||
|
||
(s/def :blaze.db.resource-handle-cache/max-size | ||
nat-int?) |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
(ns blaze.db.tx-cache | ||
"A cache for transactions. | ||
Caffeine is used because it have better performance characteristics as a | ||
ConcurrentHashMap." | ||
(:require | ||
[blaze.db.impl.index.tx-success :as tsi] | ||
[blaze.db.kv.spec] | ||
[blaze.db.tx-cache.spec] | ||
[clojure.spec.alpha :as s] | ||
[integrant.core :as ig] | ||
[taoensso.timbre :as log]) | ||
(:import | ||
[com.github.benmanes.caffeine.cache Caffeine])) | ||
|
||
|
||
(set! *warn-on-reflection* true) | ||
|
||
|
||
(defn- new-tx-cache | ||
"Creates a new transaction cache." | ||
[kv-store max-size] | ||
(-> (Caffeine/newBuilder) | ||
(.maximumSize max-size) | ||
(.recordStats) | ||
(.build (tsi/cache-loader kv-store)))) | ||
|
||
|
||
(defmethod ig/pre-init-spec :blaze.db/tx-cache [_] | ||
(s/keys :req-un [:blaze.db/kv-store] :opt-un [::max-size])) | ||
|
||
|
||
(defmethod ig/init-key :blaze.db/tx-cache | ||
[_ {:keys [kv-store max-size] :or {max-size 0}}] | ||
(log/info "Create transaction cache with a size of" max-size "transactions") | ||
(new-tx-cache kv-store max-size)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(ns blaze.db.tx-cache.spec | ||
(:require | ||
[clojure.spec.alpha :as s])) | ||
|
||
|
||
(s/def :blaze.db.tx-cache/max-size | ||
nat-int?) |
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
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
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
Oops, something went wrong.