Skip to content

Commit

Permalink
✨ Made the result more accurate + backup old data on save
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthurdw committed Aug 14, 2022
1 parent 3d61c64 commit e4500e6
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*/target
*.bincode
*.bincode*

ffly-rs/Cargo.lock
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
7 changes: 3 additions & 4 deletions ffly-rs/examples/push_it.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
7 changes: 3 additions & 4 deletions ffly-rs/examples/push_it_redis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
7 changes: 3 additions & 4 deletions ffly-rs/examples/push_it_skytable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
4 changes: 2 additions & 2 deletions server/.SRCINFO
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
5 changes: 2 additions & 3 deletions server/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -40,4 +40,3 @@ check() {
}



9 changes: 6 additions & 3 deletions server/src/database.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::{
fs::File,
fs::{rename, File},
io::{Read, Write},
path::Path,
sync::MutexGuard,
Expand Down Expand Up @@ -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();
}
}
});
Expand Down

0 comments on commit e4500e6

Please sign in to comment.