Crate freqfs

Crate freqfs 

Source
Expand description

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.

Macros§

name_from_str
Implement Name for a type which implements std::str::FromStr, to compare with a key type which dereferences to a str.

Structs§

Cache
An in-memory cache layer over tokio::fs with least-frequently-used (LFU) eviction.
Dir
A filesystem directory
DirLock
A clone-able wrapper type over a RwLock on a directory.
FileLock
A futures-aware read-write lock on a file

Enums§

DirEntry
A directory entry, either a FileLock or a sub-DirLock.

Traits§

DirDeref
A helper trait to coerce container types like Arc into a borrowed Dir.
FileDeref
A helper trait to coerce container types like Arc into a borrowed file.
FileLoad
Load a file-backed data structure.
FileSave
Write a file-backed data structure to the filesystem.
Name
A type that can be used to look up a directory entry without calling to_string(), to avoid unnecessary heap allocations.

Type Aliases§

DirReadGuard
A read lock on a directory.
DirReadGuardOwned
An owned read lock on a directory.
DirWriteGuard
A write lock on a directory.
DirWriteGuardOwned
An owned write lock on a directory.
FileReadGuard
A read guard on a file
FileReadGuardOwned
An owned read guard on a file
FileWriteGuard
A write guard on a file
FileWriteGuardOwned
An owned write guard on a file