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

Cache query documents transformed by InMemoryCache. #3553

Merged
merged 3 commits into from
Jun 6, 2018

Commits on Jun 6, 2018

  1. Cache query documents transformed by InMemoryCache.

    After #3444 removed `Map`-based caching for `addTypenameToDocument` (in
    order to fix memory leaks), the `InMemoryCache#transformDocument` method
    now creates a completely new `DocumentNode` every time it's called
    (assuming this.addTypename is true, which it is by default).
    
    This commit uses a `WeakMap` to cache calls to `addTypenameToDocument` in
    `InMemoryCache#transformDocument`, so that repeated cache reads will no
    longer create an unbounded number of new `DocumentNode` objects. The
    benefit of the `WeakMap` is that it does not prevent its keys (the
    original `DocumentNode` objects) from being garbage collected, which is
    another way of preventing memory leaks.  Note that `WeakMap` may have to
    be polyfilled in older browsers, but there are many options for that.
    
    This optimization will be important for #3394, since the query document is
    involved in cache keys used to store cache partial query results.
    
    cc @hwillson @jbaxleyiii @brunorzn
    benjamn committed Jun 6, 2018
    Configuration menu
    Copy the full SHA
    c3382d8 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    3a6d6df View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    173047c View commit details
    Browse the repository at this point in the history