Note The main branch includes many breaking changes, switch to v0.3 branch for the released version.
Basteh(previously actix-storage) is a type erased wrapper around some key-value storages to provide common operations.
Basteh is meant to be used alongside one the implementer crates, ex:
```toml
[dependencies] basteh = "0.4.0-alpha.5" basteh-memory = "0.4.0-alpha.5" ```
After you picked a backend:
```rust,ignore use basteh::{Basteh, BastehError}; use basteh_memory::MemoryBackend;
async fn handler() -> Result
// Give it to the Storage struct let basteh = Basteh::build().store(store).finish();
// Set a key, value can be stringy, bytes or numbers basteh.set("key", "value").await;
// And make it expire after 5 seconds basteh.expire("key", Duration::from_secs(5)).await;
// Or just do both in one command(usually faster) basteh.setexpiring("key", "value", Duration::fromsecs(5)).await;
basteh.get::
There is also an implementation based on sled, but because of sled's situation, it has not been released to crates.io
The word basteh
is persian for box/package, that simple! Does it sound like some other words in english? sure! But I'm bad at naming packages and my other option was testorage
as in type-erased storage... so... basteh
is cool.
The main idea for having a kv storage around while developing applications, came from my love for django framework and how it makes your life easier. There is a cache framework in django that does just that! Basteh is a bit more, it is not just for a cache but also for persistent values which is why there will always be some persistent implementations around.
Although it is designed to work with small, mostly temporary data, I don't have any plans to make it less effecient for other workflows, and pull requests are always welcome.
It can be usefull when:
There are bunch of examples in the examples
folder, very basic ones thought, but it will give you the idea.
This project is licensed under either of
at your option.