Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pollen-robotics/cache_cache
Cache for controlling and reducing IO calls
https://github.com/pollen-robotics/cache_cache
Last synced: about 1 month ago
JSON representation
Cache for controlling and reducing IO calls
- Host: GitHub
- URL: https://github.com/pollen-robotics/cache_cache
- Owner: pollen-robotics
- License: apache-2.0
- Created: 2023-01-05T09:25:53.000Z (about 2 years ago)
- Default Branch: develop
- Last Pushed: 2023-08-22T14:00:59.000Z (over 1 year ago)
- Last Synced: 2024-12-06T10:36:22.409Z (about 2 months ago)
- Language: Rust
- Homepage: https://crates.io/crates/cache_cache
- Size: 29.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cache for controlling and reducing IO calls
[![Build Status]][actions] [![Latest Version]][crates.io]
[Build Status]: https://img.shields.io/github/actions/workflow/status/pollen-robotics/cache_cache/rust.yml?branch=master
[actions]: https://github.com/pollen-robotics/cache_cache/actions?query=branch%3Amaster[Latest Version]: https://img.shields.io/crates/v/cache_cache.svg
[crates.io]: https://crates.io/crates/cache_cache## Overview
This caching library has been designed for specific use-cases where:
* getting a "fresh" value can be time consuming and can fail (eg. IOs with hardware)
* getting multiple values at once can be more efficient than getting each value independantly.Typically, its primary use was to retrieve position/speed/temperature/etc from multiple motors using serial communication. In this setup, the motors are daisy chained, and in the protocol used to communicate with them, a specific message can be used to retrieve a register value for multiple motors at once.
Many other caching implementations exist than can better fit other need.
## Documentation
### Example
```rust
use cache_cache::Cache;
use std::{error::Error, time::Duration};fn get_position(ids: &[u8]) -> Result, Box> {
// For simplicity, this function always work.
// But it's a mockup for a real world scenario where hardware IO can fail.
Ok(ids.iter().map(|&id| id as f64 * 10.0).collect())
}fn main() {
let mut present_position = Cache::with_expiry_duration(Duration::from_millis(10));present_position.insert(10, 0.0);
let pos = present_position
.entries(&[10, 11, 12])
.or_try_insert_with(get_position);assert!(pos.is_ok());
assert_eq!(pos.unwrap(), vec![&0.0, &110.0, &120.0]);
}
```See https://docs.rs/cache_cache for more information on APIs and examples.
## License
This library is licensed under the Apache License 2.0.
## Support
It's developed and maintained by [Pollen-Robotics](https://pollen-robotics.com). They developped open-source tools for robotics manipulation.
Visit https://pollen-robotics.com to learn more or join our Dicord community if you have any questions or want to share your ideas.