GithubHelp home page GithubHelp logo

tylerreisinger / cache-macro Goto Github PK

View Code? Open in Web Editor NEW
63.0 2.0 8.0 48 KB

A procedural attribute macro to automatically cache the results of a function call with given args.

License: MIT License

Rust 100.00%
rust cache procedural-macros lru

cache-macro's People

Contributors

aaron1011 avatar joshmcguigan avatar tylerreisinger avatar whentze avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cache-macro's Issues

Support cache with time to live for entries

A common use case for cacheing would be when making network calls to external services. In this case, a user might want to use a backing cache which supports a time to live for entries to ensure the data doesn't get stale.

I've created an expiring_map crate which could provide the backing data storage for this, but supporting the expiring_map cache within the lru-cache-macro would require some modifications to this crate.

I'd be wiling to attempt making a PR to add the necessary changes, if this is something you are interested in. One larger issue, however, is that it may make sense to rename this repo/crate to something more general (perhaps simply cache-macro?). Let me know what you think.

Implement a fallback error handling scheme using compile_error!

Right now, we use the proc_macro::Diagnostic interface for reporting errors. Diagnostic is able to show exact code spans and generally output the most useful information, but it is unable to be used outside of nightly right now. The compile_error! macro offers much less information to be output on error, but supporting it would allow cache-macro to be usable on stable.

A feature called nightly could be added to opt-in to the better DIagnostic interface.

Properly deny mut references

Mutable references can cause soundness issues if the argument value is modified by the function. They should be denied in get_args_and_types.

Add support for `self` arguments

There is no fundamental reason to deny self as long as it follows the same requirements as any other argument. Implementing this would require extending get_args_and_types to output the correct identifiers in the SelfValue and SelfRef arms.

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.