fitzgen / associative-cache Goto Github PK
View Code? Open in Web Editor NEWA generic, fixed-size, associative cache
Home Page: https://docs.rs/associative-cache
A generic, fixed-size, associative cache
Home Page: https://docs.rs/associative-cache
When running tests for 1.0.1 on i386, I get the following failures:
$ /usr/bin/cargo test -j12 -Z avoid-dev-deps --release --no-fail-fast --lib
running 15 tests
test replacement::lru::tests::lru_replacement ... ok
test indices::tests::pointer_two_way ... FAILED
test indices::tests::pointer_direct_mapped ... FAILED
test tests::entry ... ok
test tests::get ... ok
test tests::get_mut ... ok
test tests::capacity ... ok
test tests::insert ... ok
test tests::iter ... ok
test tests::into_iter ... ok
test tests::iter_mut ... ok
test tests::len ... ok
test tests::replacement_policy ... ok
test tests::retain ... ok
test tests::remove ... ok
failures:
---- indices::tests::pointer_two_way stdout ----
thread 'indices::tests::pointer_two_way' panicked at 'assertion failed: `(left == right)`
left: `0..2`,
right: `2..4`', src/indices.rs:185:9
---- indices::tests::pointer_direct_mapped stdout ----
thread 'indices::tests::pointer_direct_mapped' panicked at 'assertion failed: `(left == right)`
left: `2..3`,
right: `1..2`', src/indices.rs:161:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failures:
indices::tests::pointer_direct_mapped
indices::tests::pointer_two_way
test result: FAILED. 13 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
error: test failed, to rerun pass `--lib`
error: 1 target failed:
`--lib`
Hi, I was looking for something exactly like your crate for a class project. The only thing that I was wondering was the (amortized) time complexity of get
, get_mut
, insert
, and remove
? Is there significant overhead to using this associative cache over a regular hash map?
This crate claims that its license is MIT OR Apache-2.0
, but the license text is not included. Both the MIT and the Apache-2.0 licenses require including the full text when distributing the software, so users cannot comply with that license if you don't include it. Please add the license text.
context:
pub trait LruTimestamp {
type Timestamp: PartialOrd;
fn get_timestamp(&self) -> &Self::Timestamp;
}
I think this means LruTimestamp::get_timestamp()
has to return a reference to something inside self
, so it can't compute the timestamp. For example, if I want the timestamp to be self.member1 + self.member2
. Or in my case, self
is #[repr(packed)]
, so I can't[*] return a reference to a member; I want to do the unaligned dereference and return the value.
[*] or at least, rustc says it will be disallowed in a future release
I think that the interface could be changed to:
pub trait LruTimestamp {
type Timestamp: PartialOrd;
fn get_timestamp(&self) -> Self::Timestamp; // removed &
}
And then you can still return a reference to something inside self
when desired, by defining the Timestamp
type to be a reference, e.g.:
impl<T> LruTimestamp for WithLruTimestamp<T> {
type Timestamp = &Cell<Instant>; // added &
fn get_timestamp(&self) -> Self::Timestamp { // removed &
&self.timestamp
}
}
I'm not sure exactly how to do this as a non-breaking change, maybe add a new trait, LruTimestampByValue
?
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.