Giter VIP home page Giter VIP logo

Comments (8)

AuHau avatar AuHau commented on July 1, 2024

This feature is currently on-hold, until Toggl finalize their new API version (v9), which is currently in development (their web client is already using it), but is still not in stable form.

from toggl-cli.

sjvrijn avatar sjvrijn commented on July 1, 2024

While wanting to do some analysis over all my entries (~2k by now), I've tried using Python's built-in @lru_cache decorator on the api.others.toggl function: it seems to work pretty well, will submit a PR soon.
Main issues for proper inclusion into the probject would be:

  • when to automatically reset the cache in more interactive use
  • how to enable clearing through the cli
  • whether to enable by default (as it can be confusing if people don't expect it...)

Any thoughts on these?

from toggl-cli.

AuHau avatar AuHau commented on July 1, 2024

That is cool! Somehow I did not think of using @lru_cache directly. I guess it can actually work!

I originally wanted to implement a custom cache in order to use the bulk fetching capabilities of the Toggl's API. I am reluctant to work on that before they will release the new API version, but until then it is definitely a good idea to use at least lru_cache!

Regarding your points. Clearing for CLI is not really necessary, because to my knowledge lru_cache is a memory only, hence when the CLI process will die, the cache will disappear too. Hence a bigger problem will be with long-running projects...

I would add a new property to utils.Config which will enable/disable usage of caching. Maybe we could use logic to enable caching by default for CLI, but for using the API wrappers it would be by default turned off? What do you think?

Also, I would document that with mentioning that you can clear the cache using api.others.toggl.cache_clear() call.

Thanks for the idea!

from toggl-cli.

sjvrijn avatar sjvrijn commented on July 1, 2024

Clearing the cache would still be useful if I e.g. fetch a project, update it and then fetch it again (directly or indirectly). In that case, the old version will still be cached, even though I just updated it. Any update call could then clear the cache to force remote updates without having to check anything.

So I think I would enable it by default for both, but allow changing the cache size through the .togglrc file, where setting it to 0 should disable it I think.

from toggl-cli.

AuHau avatar AuHau commented on July 1, 2024

Hmm, by your example you are pointing to CLI usage? Or generally? It is definitely a valid case for the API Wrappers but not really for CLI...
Yup, updates should clear the cache. lru_cache unfortunately does not allow you to invalidate specific entries.

Yeah, a configuration of the size of the cache is definitely a good idea, but I would still keep it separate from turning on/off caching. Hence having a general boolean flag for having it turned on/off and then another option for the size of the cache.

from toggl-cli.

Exr0n avatar Exr0n commented on July 1, 2024

Hi,

Any updates on this? I would just like to be able to cache API calls so the list loads faster.

from toggl-cli.

AuHau avatar AuHau commented on July 1, 2024

I don't plan to tackle this in any close future. I guess @sjvrijn also does not really work on it anymore.

If you would be interested to work on the PR let me know! It would be most welcome!

from toggl-cli.

Exr0n avatar Exr0n commented on July 1, 2024

I could take a look, although I'm not too familiar with the frameworks used in this project. What needs to happen?

from toggl-cli.

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.