Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spec for plan-cache is wrong #88

Closed
markaddleman opened this issue Aug 12, 2021 · 1 comment
Closed

Spec for plan-cache is wrong #88

markaddleman opened this issue Aug 12, 2021 · 1 comment
Labels
bug Something isn't working
Projects

Comments

@markaddleman
Copy link

From slack conversation: https://clojurians.slack.com/archives/C87NB2CFN/p1628795228076000

the plan-cache spec should allow for pcache/CacheStore protocol

(ns pathom3.experiment
  (:require [com.wsscode.pathom3.connect.operation :as pco]
            [com.wsscode.pathom3.connect.indexes :as pci]
            [com.wsscode.pathom3.interface.eql :as p.eql]
            [com.wsscode.pathom3.connect.built-in.resolvers :as pbir]
            [com.wsscode.pathom3.connect.planner :as pcp]
            [clojure.core.cache.wrapped :as cc]
            [com.wsscode.pathom3.cache :as pcache]))


(defrecord CoreCacheStore [cache-atom]
  pcache/CacheStore
  (-cache-lookup-or-miss [_ cache-key f]
    (cc/lookup-or-miss cache-atom cache-key (fn [_] (f))))

  (-cache-find [_ cache-key]
    (find @cache-atom cache-key)))


(pco/defresolver a []
  {::pco/output [:a]}
  {:a "hello world"})

(defn new-env []
  (-> (pci/register [a])
      (pcp/with-plan-cache (->CoreCacheStore (cc/lu-cache-factory {} :threshold 1024)))))

(comment
  (p.eql/process (new-env) {} [:a]))
@wilkerlucio wilkerlucio added the bug Something isn't working label Aug 12, 2021
@wilkerlucio wilkerlucio added this to To do in Pathom 3 via automation Aug 12, 2021
@wilkerlucio
Copy link
Owner

Fixed by b7b3294

Pathom 3 automation moved this from To do to Done Aug 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

No branches or pull requests

2 participants