FileDB is a Zig-based implementation of the Bitcask storage model, designed for efficient and reliable key-value storage. With fast O(1) record fetching and a compaction mechanism that maintains performance, this solution is tailored for high-throughput applications while ensuring minimal disk I/O.
FileDB is a disk-based key-value store that draws inspiration from the Bitcask architecture, designed to provide efficient storage and retrieval of data. This Zig implementation leverages a log-structured hashtable for storing record metadata, while maintaining an open disk file for appending records. On reaching a predefined disk space limit or during system restarts, the system rotates disk files, ensuring that older files remain accessible exclusively for reading.
init(allocator: std.mem.Allocator, options: ?config.Options): Initializes the FileDB instance.deinit(): De-initializes the FileDB, releasing resources.put(key:[]const u8, value: []const u8): Inserts a key-value pair into the database.get(key:[]const u8): Retrieves the value associated with a given key.delete(key: []const u8): Removes a key-value pair from the database.list(allocator: std.mem.Allocator): Lists all keys stored in the database.sync(): Syncs the current open datafile with the disk.storeHashMap(): Creates a HINTS file for optimized data retrieval.loadKeyDir(): Loads the hashmap from the HINTS file for efficient access.A Redis-compatible client is provided alongside the FileDB library, allowing users to interact with the database using familiar Redis commands. Here are some command examples:
127.0.0.1:6379> RING
(error) ERR unknown command
127.0.0.1:6379> PING
PONG
127.0.0.1:6379> get abcd
(nil)
127.0.0.1:6379> set abcd def
OK
127.0.0.1:6379> get abcd
"def"
The performance of FileDB has been validated through comprehensive benchmarking against standard Redis commands. Below are some key performance results:
FileDB is ideal for developers seeking a lightweight and high-performance key-value store solution that efficiently manages large datasets while remaining compatible with Redis tooling.
No comments yet.
Sign in to be the first to comment.