tylerreisinger / cache-macro Goto Github PK
View Code? Open in Web Editor NEWA procedural attribute macro to automatically cache the results of a function call with given args.
License: MIT License
A procedural attribute macro to automatically cache the results of a function call with given args.
License: MIT License
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.
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.
Mutable references can cause soundness issues if the argument value is modified by the function. They should be denied in get_args_and_types
.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.