diff --git a/.gitignore b/.gitignore index d229e1f..e17d61a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ */target -*.bincode +*.bincode* ffly-rs/Cargo.lock diff --git a/README.md b/README.md index 519e191..98b7c98 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ ![Firefly](./assets/logo.png) -> **⚠️ NOTE**: This project is still in development, and not yet ready for production usage. - An optimized tweaked key-value pair database. It is a simple, fast, and secure. At [Xiler](https://www.xiler.net) it gets used to store and manage client sessions throughout the platform. diff --git a/ffly-rs/examples/push_it.rs b/ffly-rs/examples/push_it.rs index b1a8ac3..03ae98e 100644 --- a/ffly-rs/examples/push_it.rs +++ b/ffly-rs/examples/push_it.rs @@ -39,14 +39,13 @@ async fn main() { ); let start = Instant::now(); futures::future::join_all(futures).await; + let elapsed = start.elapsed(); println!( "Created {} new records by using {} connections in {:?}.", - REQUESTS_TOTAL, - THREADS, - start.elapsed() + REQUESTS_TOTAL, THREADS, elapsed ); println!( "This comes down to {} requests per second.", - REQUESTS_TOTAL / start.elapsed().as_secs() as usize + REQUESTS_TOTAL / elapsed.as_secs() as usize ); } diff --git a/ffly-rs/examples/push_it_redis.rs b/ffly-rs/examples/push_it_redis.rs index 2fa891c..e300e44 100644 --- a/ffly-rs/examples/push_it_redis.rs +++ b/ffly-rs/examples/push_it_redis.rs @@ -41,14 +41,13 @@ async fn main() { ); let start = Instant::now(); futures::future::join_all(futures).await; + let elapsed = start.elapsed(); println!( "Created {} new records by using {} connections in {:?}.", - REQUESTS_TOTAL, - THREADS, - start.elapsed() + REQUESTS_TOTAL, THREADS, elapsed ); println!( "This comes down to {} requests per second.", - REQUESTS_TOTAL / start.elapsed().as_secs() as usize + REQUESTS_TOTAL / elapsed.as_secs() as usize ); } diff --git a/ffly-rs/examples/push_it_skytable.rs b/ffly-rs/examples/push_it_skytable.rs index a10632e..4719279 100644 --- a/ffly-rs/examples/push_it_skytable.rs +++ b/ffly-rs/examples/push_it_skytable.rs @@ -40,14 +40,13 @@ async fn main() { ); let start = Instant::now(); futures::future::join_all(futures).await; + let elapsed = start.elapsed(); println!( "Created {} new records by using {} connections in {:?}.", - REQUESTS_TOTAL, - THREADS, - start.elapsed() + REQUESTS_TOTAL, THREADS, elapsed ); println!( "This comes down to {} requests per second.", - REQUESTS_TOTAL / start.elapsed().as_secs() as usize + REQUESTS_TOTAL / elapsed.as_secs() as usize ); } diff --git a/server/.SRCINFO b/server/.SRCINFO index e620e2e..f487e40 100644 --- a/server/.SRCINFO +++ b/server/.SRCINFO @@ -1,7 +1,7 @@ pkgbase = ffly pkgdesc = An "blazingly" fast key-value pair database without bloat written in rust - pkgver = 0.0.1 - pkgrel = 2 + pkgver = 0.0.2 + pkgrel = 1 url = https://github.com/Arthurdw/firefly arch = x86_64 arch = i686 diff --git a/server/Cargo.toml b/server/Cargo.toml index b574f33..ebda242 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ffly" -version = "0.0.1" +version = "0.0.2" edition = "2021" description = "A \"blazingly\" fast key-value pair database without bloat written in rust." license = "MIT" diff --git a/server/PKGBUILD b/server/PKGBUILD index 05534dd..2a631bf 100644 --- a/server/PKGBUILD +++ b/server/PKGBUILD @@ -2,8 +2,8 @@ _name=ffly _loc="firefly/server" pkgname=${_name} -pkgver=0.0.1 -pkgrel=2 +pkgver=0.0.2 +pkgrel=1 pkgdesc="An \"blazingly\" fast key-value pair database without bloat written in rust" arch=(x86_64 i686) url="https://github.com/Arthurdw/firefly" @@ -40,4 +40,3 @@ check() { } - diff --git a/server/src/database.rs b/server/src/database.rs index 5471fce..96316ce 100644 --- a/server/src/database.rs +++ b/server/src/database.rs @@ -1,5 +1,5 @@ use std::{ - fs::File, + fs::{rename, File}, io::{Read, Write}, path::Path, sync::MutexGuard, @@ -178,9 +178,12 @@ pub fn detect_changes(db: Db, changed: Changed, file_path: String, interval: u64 let buffer = bincode::serialize(&db.to_owned()).unwrap(); drop(db); - let compressed = buffer; + if Path::new(&file_path).exists() { + rename(&file_path, format!("{}{}", file_path, ".bak")).unwrap(); + } + let mut file = File::create(&file_path).unwrap(); - file.write_all(&compressed).unwrap(); + file.write_all(&buffer).unwrap(); } } });