Comments (5)
Rust 1.30 (including proc macro) is released now.
https://blog.rust-lang.org/2018/10/25/Rust-1.30.0.html
from cached.
I was having some issues with rust complaining that it couldn't figure out what type to use for return values with the regular macro so I decided to give this a shot.
Here's the list of attributes that I'm working on (all of these are optional)
- name =
String
- cache name (default is uppercase of function name) - unbound - use unbound cache (default cache type)
- size =
usize
- use sized cache - time =
u64
- use timed cache - key = "
Type
" - the type to be used for the cache (required when convert is set) - convert = "
Block
" - use a block to convert inputs into the key (required when key is set) - result - only cache the result if it is
Ok
- option - only cache the result if it is
Some
I'm using darling for the attributes parsing and it doesn't implement parsing Type
or Block
so right now the key type and convert block both have to be put in a string and parsed separately.
I should have the unwrap attribute implemented on Friday or Saturday.
Once I have that done I'll fork, add the proc macro as a sub crate, and make a pull request.
Edit: I realized that having one attribute for both result and option wouldn't work since it would have to be based on parsing out the return type name and the user could have aliased the result/option type or be using their own. I changed it to be separate result/option attributes.
from cached.
I would love to. I haven't been following proc_macros
though, are they going to be stable soon? I probably won't do anything until they're in stable
from cached.
Yes, it does.
rust-lang/rust#38356 (comment)
from cached.
I finished with this set of attributes, now I'm going fork and add as a subcrate.
I'm using the visibility of the input function for the output function and cache so this should also fix #15.
from cached.
Related Issues (20)
- How to get all cached values? HOT 1
- Feature Request: Floating-Point ttl HOT 4
- Add feature for usage of `redis::aio::ConnectionManager` to help to recover from redis server restarts HOT 1
- `async_once` is unsound HOT 2
- Allow reexport
- sync_writes isn't working correctly when different values for function parameters are used HOT 5
- Tokio included when not using async HOT 1
- Documentation on docs.rs for `stores` module does not exist
- Cannot use `inner` as parameter name HOT 2
- Any plan on Set collection? HOT 1
- Retrieve cache expiration time from cached function result
- Also generate the fresh data function HOT 2
- Cannot call *_no_cache function HOT 3
- `failed to resolve: could not find `async_sync` in `cached`` HOT 2
- Once with sync_writes and async causes deadlocks in tokio.
- Unnecessary `&mut V` with `get_or_set_with` and `try_get_or_set_with` (CachedAsync)
- Feature: Ability to configure (or reconfigure) a SizedCache `size` based on runtime data HOT 4
- 2021 edition?
- Async disk cache HOT 4
- Add helper attribute to ignore arguments HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cached.