question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use https://github.com/Herteby/denormalize Depend on this package with {weak: true} Check for package existence when specifying cache, and give instructions on how to install it.

API

Invoice.addLinks({
    user: {
        collection: Users,
        cache: {
            field: 'userCache',
            body: { firstName: 1, lastName: 1 }
       }
    }
});

When query-ing for invoices, if a link is cached, fetch from cache IF and only IF ALL the specified fields exist in cache.

{ invoices: { user: { firstname: 1, lastname: 1} }

This will actually fetch ‘userCache.firstname’, ‘userCache.lastname’

However, if there is an extra field, then caching is bypassed.

If user contains a nested field like: profile: { firstname, lastname }

We need to be careful when we have:

Invoice.addLinks({
    user: {
        collection: Users,
        cache: {
            field: 'userCache',
            body: {
                   profile: { firstName: 1, lastName: 1},
                   lastLogin: 1
            }
       }
    }
});

If we query: invoices: { user: { profile: { firstName: 1 }, lastLogin: 1 } } It will still only hit the cache.

The logic is that the requested body needs to be a sub-body from profile.

Same logic applies for reactive queries as well, transforming the CollectionNode into a Cache node.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
Hertebycommented, Nov 28, 2017

You could use my bypassSchema option, which doesn’t depend on SimpleSchema, but maybe that could lead to problems elsewhere…

Aah now I understand what you meant by disabling denormalization - just if you have $filters on a link. Yeah that’s fine, I thought you meant on the root query, that puzzled me a bit 😛

0reactions
theodorDiaconucommented, Nov 28, 2017

@Herteby bypassSchema option is allowed in the cache: {}, now named denormalize: {} configuration.

Read more comments on GitHub >

github_iconTop Results From Across the Web

DeepCache: Principled Cache for Mobile Deep Vision - arXiv
DeepCache benefits model execution efficiency by exploiting temporal locality in input video streams. It addresses a key challenge raised by ...
Read more >
DeepCache: Principled Cache for Mobile Deep Vision
DeepCache benefits model execution efficiency by exploiting temporal locality in input video streams. It addresses a key challenge raised by ...
Read more >
Deep clearing of Chrome browser cache - Documentation
This article will show you a method of deep clearing Chrome's cache that seems to work consistently, especially when dealing with new releases...
Read more >
DeepCache: Principled Cache for Mobile Deep Vision
Mobile Deep Vision ... Just cache/reuse the final results based on input image ... Cache erosion – reusability tends to diminish at its...
Read more >
Quiver: An Informed Storage Cache for Deep Learning - USENIX
Quiver: An Informed Storage Cache for Deep Learning. Authors: Abhishek Vijaya Kumar and Muthian Sivathanu, Microsoft Research India.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found