1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//! # bincache
//!
//! `bincache` is a versatile, high-performance, async-first binary data caching library for Rust, designed with a focus on flexibility, efficiency, and ease of use. It enables developers to store, retrieve, and manage binary data using various caching strategies, catering to different storage needs and optimization requirements.
//!
//! The library offers several caching strategies out of the box:
//!
//! * **Memory**: This strategy stores all the data directly in memory. It is ideal for smaller sets of data that need to be accessed frequently and quickly.
//! * **Disk**: This strategy saves data exclusively to disk storage. It is best suited for large data sets that don't need to be accessed as often or as swiftly.
//! * **Hybrid**: This strategy is a combination of memory and disk storage. It stores data in memory first, and swaps to disk for files that don't fit the memory limit.
//!
//! We also offer opt-in support for data compression:
//!
//! * **zstd**: Enabled using the `comp_zstd` feature flag.
//! * more to come...
//!
//! This crate is intended to be versatile, serving as an efficient solution whether you're developing a high-load system that needs to reduce database pressure, an application that requires quick access to binary data, or any other situation where efficient caching strategies are vital.
//!
//! ## Usage
//!
//! Add `bincache` to your `Cargo.toml` dependencies:
//!
//! ```sh,no_run
//! cargo add bincache # for stdlib I/O
//! cargo add bincache --features rt_tokio_1 # for tokio I/O
//! cargo add bincache --features rt_async-std_1 # for async-std I/O
//! ```
//!
//! ## Examples
//!
//! Getting started quickly using ready-made aliased cache builders:
//!
//! ```
//! use bincache::MemoryCacheBuilder;
//!
//! # #[tokio::main(flavor = "current_thread")]
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let mut cache = MemoryCacheBuilder::default().build().await?;
//! cache.put("key", b"value".to_vec()).await?;
//! # Ok(())
//! # }
//! ```
//!
//! More advanced usage, using the builder directly:
//!
//! ```
//! use bincache::{Cache, CacheBuilder, MemoryStrategy};
//!
//! # #[tokio::main(flavor = "current_thread")]
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let mut cache = CacheBuilder::default()
//! .with_strategy(MemoryStrategy::default())
//! .build().await?;
//! cache.put("key", b"value".to_vec()).await?;
//! # Ok(())
//! # }
//! ```
//!
//! ## License
//!
//! bincache is licensed under the MIT license.
//!
compile_error!;
compile_error!;
pub use Result;
pub use disk_util as DiskUtil;
// Export basic types
pub use Cache;
pub use CacheBuilder;
pub use CacheCapacity;
pub use NO_COMPRESSION;
pub use Error;
pub use Noop;
pub use *;
// Export typed caches and builders
reexport_strategy!;
reexport_strategy!;
reexport_strategy!;
// README doctests
;