ribelo / doxa

The Unlicense
232 stars 8 forks source link

cache not detecting change #24

Closed stevebuik closed 2 years ago

stevebuik commented 2 years ago
(let [db1 (dx/create-dx [] {::dx/with-diff? true})
        people (fn [db]
                 (->
                   ^{::dx/cache ::people}                   ; comment this out to see correct behaviour
                   (dx/q [:find ?name ...
                          :where
                          [?e :name ?name]]
                         db)))
        r1 (people db1)
        db2 (->> [{:id   "20"
                   :name "Chris"}]
                 (vector :dx/put)
                 (dx/commit db1))
        r2 (people db2)]
    {:initial r1
     :updated r2})
stevebuik commented 2 years ago

I could be a bug in my understanding of the readme. I'll be happy if that's true

stevebuik commented 2 years ago

I found the specific case where caching is not working. updated the example above.

empty results from a cached query break the change detection.

ribelo commented 2 years ago

I added another test, but did not mark the issue in the commit. It seems to be working.

stevebuik commented 2 years ago

still not working for me. I have layer2 returning cached ids, layer 3 mapping a d/pull over those ids.

layer3 always sees an empty array, even when the db has data loaded i.e. cache returning stale empty vector

stevebuik commented 2 years ago

verified fix now working. fresh cached results returned after re-frame txns