Skip to content

Commit

Permalink
give the history resolver its own cache key prefix
Browse files Browse the repository at this point in the history
If the exact same node key came through the Resolver the CachedHistoryRangeResolver
could return the results cached by the CachedTRangeResolver, since they shared the same
cache key prefix. This gives it a unique prefix.
  • Loading branch information
dpetran committed Feb 3, 2023
1 parent 6fb8d24 commit fe1fa31
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/fluree/db/index.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@
(if (branch? node)
(resolve node-resolver node)
(async-cache
[::t-range id tempid tt-id from-t to-t]
[::history-t-range id tempid tt-id from-t to-t]
(fn [_]
(go-try
(let [resolved (<? (resolve node-resolver node))
Expand Down
5 changes: 1 addition & 4 deletions src/fluree/db/query/range.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,10 @@
range-set (flake/sorted-set-by cmp start-flake end-flake)
in-range? (fn [node] (intersects-range? node range-set))
query-xf (extract-query-flakes {:idx idx
:from-t from-t
:to-t to-t
:start-test start-test
:start-flake start-flake
:end-test end-test
:end-flake end-flake
:flake-limit limit})]
:end-flake end-flake})]
(go-try
(let [history-ch (->> (index/tree-chan resolver idx-root in-range? resolved-leaf? 1 query-xf error-ch)
(filter-authorized db start-flake end-flake error-ch)
Expand Down
4 changes: 3 additions & 1 deletion test/fluree/db/query/history_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@
{:f/t 2
:f/assert [{:ex/x "foo-2" :id :ex/dan}]
:f/retract [{:ex/x "foo-1" :id :ex/dan}]}
{:f/t 1 :f/assert [{:ex/x "foo-1" :id :ex/dan}] :f/retract []}]
{:f/t 1
:f/assert [{:ex/x "foo-1" :id :ex/dan}]
:f/retract []}]
@(fluree/history ledger {:history [:ex/dan :ex/x] :t {:to 3}}))))
(testing "t-range"
(is (= [{:f/t 4
Expand Down

0 comments on commit fe1fa31

Please sign in to comment.