
Product
Introducing Pull Request Stories to Help Security Teams Track Supply Chain Risks
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
Simple cache written for reducing frequent access / compute expensive operation (as of now, it serves only as experimental, not intended for production yet)
This implementation is based on "LRU Cache", with another inspiration comes from "Writing a doubly linked list in Rust is easy".
Add following dependencies to Cargo.toml
[dependencies]
aba-cache = { version = "0.1.0", default-features = false }
on your main.rs
use aba_cache as cache;
fn main() {
// create Cache, with multiple_cap set to 2
// and entry will be timeout after 10 seconds
let mut cache = cache::LruCache::<usize, &str>::new(2, 10);
cache.put(1, "a");
cache.put(2, "b");
cache.put(2, "c");
cache.put(3, "d");
assert_eq!(cache.get(&1), Some(&"a"));
assert_eq!(cache.get(&2), Some(&"c"));
assert_eq!(cache.get(&3), Some(&"d"));
}
Add following dependencies to Cargo.toml
[dependencies]
aba-cache = { version = "0.1.0" }
tokio = { version = "0.2", features = ["macros", "rt-core"] }
on your main.rs
use aba_cache as cache;
#[tokio::main]
async fn main() {
// create Cache, with multiple_cap set to 2
// and entry will be timeout after 10 seconds
// additionally, this setup runtime daemon to evict outdate entry
// every 10 seconds
let cache = cache::LruAsyncCache::<usize, &str>::new(2, 10);
cache.put(1, "a").await;
cache.put(2, "b").await;
cache.put(2, "c").await;
cache.put(3, "d").await;
assert_eq!(cache.get(&1).await, Some("a"));
assert_eq!(cache.get(&2).await, Some("c"));
assert_eq!(cache.get(&3).await, Some("d"));
}
FAQs
Unknown package
We found that aba-cache demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.