Import
[]
= { = "0.0.1" }
About The Project
A rust crate to cache ROM in memory like CPU caching RAM.
Trait Cacheable is provided to let user define how to load and store data in Secondary Storage.
get and get_mut will lock the CacheGroup, then load and upgrade LRU.
- get (RwLockReadGuard)
- cache hit: return
CacheReffrom cache. - cache busy:
CacheError::Busy, cannot evict LRU-chosenCacheLinesince being used. - cache locked:
CacheError::Locked, cannot get read-lock while writing.
- get_mut (RwLockWriteGuard)
- cache hit: return
CacheMutfrom cache, and dereferenceCacheMutwill setCacheLinedirty. - cache busy:
CacheError::Busy, cannot evict LRU-chosenCacheLinesince being used. - cache locked:
CacheError::Locked, cannot get write-lock while reading or writing.
Any dirty CacheLine will be written back (Cacheable::store()) to Secondary Storage when evicted.
Features
nightly: enable#![feature(trait_upcasting)]to simplify theCacheabletrait. (Nightly Rust is needed)
Built With
- Rust
- Miri (Testing)
- Loom (Concurrency Testing)
Usage
Example
# use Cache;
// e.g 2-way set associative cache (8 sets/groups)
let cache: = Defaultdefault;
cache..unwrap;
cache..unwrap;
For more examples, please refer to the Tests, Example or Documentation
Changelog
todo
Roadmap
- allow concurrent access
- auto load when getting
- benchmark
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
License
Distributed under the MIT License. See LICENSE.txt for more information.
Contact
Louis - 836250617@qq.com
Project Link: https://github.com/kingwingfly/rom-cache