Crates.io | queue-file |
lib.rs | queue-file |
version | 1.4.10 |
source | src |
created_at | 2019-06-24 07:55:45.45316 |
updated_at | 2023-03-17 20:56:24.034494 |
description | queue-file is a lightning-fast, transactional, file-based FIFO |
homepage | https://github.com/ing-systems/queue-file |
repository | https://github.com/ing-systems/queue-file |
max_upload_size | |
id | 143148 |
size | 74,040 |
queue-file is a lightning-fast, transactional, file-based FIFO.
Addition and removal of an element from the queue is an O(1) operation and is atomic. Writes are synchronous by default; data will be written to disk before an operation returns.
queue-file crate is a feature complete and binary compatible port of QueueFile
class from
Tape2 by Square, Inc. Check the original project here.
To use queue-file
, first add this to your Cargo.toml
:
[dependencies]
queue-file = "1"
use queue_file::QueueFile;
fn main() {
let mut qf = QueueFile::open("example.qf")
.expect("cannot open queue file");
qf.add("ELEMENT #1".as_bytes()).expect("add failed");
qf.add("ELEMENT #2".as_bytes()).expect("add failed");
qf.add("ELEMENT #3".as_bytes()).expect("add failed");
qf.remove().expect("remove failed");
for (index, elem) in qf.iter().enumerate() {
println!(
"{}: {} bytes -> {}",
index,
elem.len(),
std::str::from_utf8(&elem).unwrap_or("<invalid>")
);
}
qf.clear().expect("clear failed");
}
Current MSRV is 1.58.1
This project is licensed under the Apache 2.0 license.