108 releases (52 stable)
Uses new Rust 2024
| new 1.30.0 | Jun 4, 2026 |
|---|---|
| 1.25.1 | Apr 30, 2026 |
| 1.17.0 | Mar 31, 2026 |
| 1.0.3 | Dec 24, 2025 |
| 1.0.0-rc.6 | Nov 26, 2025 |
#72 in Database implementations
2,103 downloads per month
Used in 22 crates
(20 directly)
145KB
2.5K
SLoC
High-performance file database for PHP projects.
This crate provides an efficient in-memory database for managing collections of PHP source files. It offers two complementary database types optimized for different access patterns:
Database: Mutable builder optimized for modifications (add, update, delete)ReadDatabase: Immutable snapshot optimized for high-performance reads
Architecture
The database uses a two-phase approach:
- Build Phase: Use
Databaseto load files, make modifications, and track changes - Query Phase: Convert to
ReadDatabaseviaDatabase::read_onlyfor fast lookups
Key Features
- Fast Lookups: O(1) average-time access by ID, name, or filesystem path
- Change Tracking: Record and batch apply file modifications via
ChangeLog - Deterministic Iteration:
ReadDatabaseguarantees consistent iteration order - Parallel Operations: Concurrent file I/O and processing support
- Type Safety: Strong typing with stable
FileIdhandles
Common Workflow
Loading Files
Use loader::DatabaseLoader to scan a project directory:
The loader handles file discovery, exclusion patterns, and parallel loading.
Querying Files
Both database types implement DatabaseReader for uniform access:
Modifying Files
Use ChangeLog to batch modifications:
Changes can be applied to the database and optionally written to disk in parallel.
Performance Characteristics
Database (Mutable)
- Add/Update/Delete: O(1) average
- Lookup by ID/name: O(1) average
- Iteration: Unordered
- Memory: ~2x file count (maps for bidirectional lookup)
ReadDatabase (Immutable)
- Creation: O(n log n) for sorting
- Lookup by ID/name/path: O(1) average
- Iteration: Deterministic, sorted by
FileId - Memory: ~3x file count (vector + 3 index maps)
Thread Safety
Database is not thread-safe and should be used from a single thread during construction.
ReadDatabase can be freely shared across threads for concurrent read access.
Dependencies
~9–23MB
~201K SLoC