GithubHelp home page GithubHelp logo

Manually setting cache about villus HOT 7 OPEN

betweenbrain avatar betweenbrain commented on June 1, 2024
Manually setting cache

from villus.

Comments (7)

logaretm avatar logaretm commented on June 1, 2024 1

Sorry for the delay, just got around to this. The plugin doesn't exposesetCacheResult, only the clear method.

But I guess we could expose it, will try to tackle it this week. PR is welcome as well, thanks for reporting this.

from villus.

betweenbrain avatar betweenbrain commented on June 1, 2024

Thanks for the response! And, now I owe you an apology for the delay 😆

Would exposing it be as simple as adding something like cachPlugin.setCacheResult = setCacheResult(operation, result); to https://github.com/logaretm/villus/blob/main/packages/villus/src/cache.ts#L80?

from villus.

logaretm avatar logaretm commented on June 1, 2024

Hello, it is the other way around. Sorry, I didn't find the time to work on it, busy with vee-validate at the moment.

It is as simple as you suggested. But how would you set the cache yourself? Would you pass an object containing the query and variables? Because it relies on key being provided, so it might be worth regenerating the key before then.

cachPlugin.setCacheResult = function (operation, result) {
  // getQueryKey imported from utils
  const key = operation.key || getQueryKey(operation);
 setCacheResult({ key, ...operation }, result);
}

from villus.

betweenbrain avatar betweenbrain commented on June 1, 2024

Hello, thanks again for the response. No apologies are needed!

But how would you set the cache yourself? Would you pass an object containing the query and variables?

Yes, that's exactly how I was thinking we would do it.

Is there anything that I can do to help move this forward?

from villus.

logaretm avatar logaretm commented on June 1, 2024

Is there anything that I can do to help move this forward?

Feel free to PR it if you have the time, I know it's a 1 liner but I usually do open-source on weekends and whenever I can sneak in work days. I will take it on by the weekend if you won't have the time.

from villus.

betweenbrain avatar betweenbrain commented on June 1, 2024

Great! PR submitted at #198. I hope that helps.

from villus.

betweenbrain avatar betweenbrain commented on June 1, 2024

@logaretm do you have a chance to review the above PR? Thanks!

from villus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.