#cache #io #file-io #file-path #file

freqfs

An in-memory filesystem cache layer over tokio::fs, with LFU eviction

20 releases

0.9.1 Dec 20, 2023
0.9.0 Nov 6, 2023
0.8.2 Sep 3, 2023
0.8.1 Jul 24, 2023
0.4.3 Sep 28, 2021

#63 in Caching

Download history 145/week @ 2023-12-20 25/week @ 2023-12-27 8/week @ 2024-01-03 11/week @ 2024-01-10 9/week @ 2024-01-17 34/week @ 2024-01-24 18/week @ 2024-01-31 8/week @ 2024-02-07 26/week @ 2024-02-14 67/week @ 2024-02-21 42/week @ 2024-02-28 33/week @ 2024-03-06 56/week @ 2024-03-13 36/week @ 2024-03-20 53/week @ 2024-03-27 58/week @ 2024-04-03

211 downloads per month
Used in 14 crates (9 directly)

Apache-2.0

61KB
1.5K SLoC

freqfs

An in-memory filesystem cache layer based on tokio::fs, with least-frequently-used eviction


lib.rs:

freqfs is an in-memory cache layer over tokio::fs with least-frequently-used eviction.

freqfs automatically caches the most frequently-used files and backs up the others to disk. This allows the developer to create and update large collections of data purely in-memory without explicitly sync'ing to disk, while still retaining the flexibility to run on a host with extremely limited memory. This is especially useful for web serving, database, and data science applications.

See the examples directory for detailed usage examples.

This crate assumes that file paths are valid Unicode and may panic if it encounters a file path which is not valid Unicode.

It also assumes that all file I/O under the cache root directory (the one whose path is passed to load) is routed through the cache (not e.g. via tokio::fs or std::fs elsewhere). It may raise an std::io::Error or panic if this assumption is not valid.

In the case that your program may not have permission to write to a filesystem entry, be sure to check the permissions before modifying it. The background cleanup thread will panic if it attempts an impermissible write operation.

Dependencies

~4–6.5MB
~111K SLoC