https://github.com/jobala/petro
A simple key value storage engine
https://github.com/jobala/petro
Last synced: 6 months ago
JSON representation
A simple key value storage engine
- Host: GitHub
- URL: https://github.com/jobala/petro
- Owner: jobala
- License: mit
- Created: 2025-06-29T16:44:19.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-08-28T14:57:08.000Z (10 months ago)
- Last Synced: 2025-08-28T21:55:15.616Z (10 months ago)
- Language: Go
- Size: 46.9 KB
- Stars: 9
- Watchers: 0
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# petro
A simple key value storage engine
## Getting Started
### Installation
`go get github.com/jobala/petro`
### Put
```go
store, err := index.New[string, int]("index", dbFile)
ok, err := store.Put("age", 25)
```
### Get
```go
store := index.New[string, int]("index", dbFile)
val, err := store.Get("age")
```
### Delete
```go
store := index.New[string, int]("index", dbFile)
val, err := store.Delete("age")
```
### PutBatch
```go
ages := map[string]int{
"john": 30,
"jane": 20,
"doe": 45
}
store := index.New[string, int]("index", dbFile)
err := store.PutBatch(ages)
```
### GetKeyRange
```go
ages := map[string]int{
"john": 30,
"jane": 20,
"doe": 45
}
store := index.New[string, int]("index", dbFile)
store.GetKeyRange("doe", "jane")
```
### Iterate
```go
ages := map[string]int{
"john": 30,
"jane": 20,
"doe": 45
}
store := index.New[string, int]("index", dbFile)
storeIter := store.GetIterator()
for !storeIter.IsEnd() {
key, val, err := storeIter.Next()
}
```
### durability
call `store.flush()` to ensure that your data is written to disk
## Design Notes
- [Disk Management](https://japhethobala.com/posts/technical/db-disk-mgmt)
- [Bufferpool Management](https://japhethobala.com/posts/technical/db-buffer-mgmt/)
## Roadmap
- [x] Disk Management
- [x] Bufferpool Management
- [x] Index Management
- [x] GetValue
- [x] Insert
- [x] Iterator
- [ ] Delete
- [ ] Support duplicate keys
- [ ] Transactions
- [ ] Recovery