cargo-pants
cargo-pants copied to clipboard
Cache results, to prevent rate limiting
Thanks for creating an issue! Please fill out this form so we can be sure to have all the information we need, and to minimize back and forth.
- What are you trying to do?
Similar to nancy
, you can cache the results of reaching out to OSSIndex, to prevent rate limiting. These results should be cached for 12 hours, and then removed from the cache if that TTL has expired.
- What feature or behavior is this required for?
It will hopefully help people avoid hitting rate limits.
- How could we solve this issue? (Not knowing is okay!)
@jdillon can likely share some info on this, there's a generic implementation for what Jason did with our Java tooling, this can likely follow that.
At a minimum your API probably needs:
- Ability to clean the cache (and a new flag for the cli to let someone do this)
- An ability to insert an item into the cache (will likely check if it exists before inserting)
- An ability to get from the cache (will error if item is expired, so someone knows to update it)
Likely it would be nice to make the TTL configurable, but the default should be 12 hours.
The cache should be saved at ~/.ossindex/cargo-pants
so that it's in a common location.
- Anything else?
Potentially look at: https://docs.rs/pickledb/0.4.1/pickledb/ or https://docs.rs/tinydb/0.0.7/tinydb/
The most i know about rust so far is how to print a hello world haha but if this isn't being done atm I'd like to try it out
Some code you could mimic can be found at: https://github.com/sonatype-nexus-community/go-sona-types/blob/master/ossindex/internal/cache/cache.go