https://github.com/hslam/wal
Package wal implements write-ahead logging.
https://github.com/hslam/wal
batch-write go golang log mmap segment wal write-ahead-logging
Last synced: about 1 year ago
JSON representation
Package wal implements write-ahead logging.
- Host: GitHub
- URL: https://github.com/hslam/wal
- Owner: hslam
- License: mit
- Created: 2020-08-06T18:29:06.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-06-14T14:00:58.000Z (almost 5 years ago)
- Last Synced: 2023-07-27T18:04:44.906Z (almost 3 years ago)
- Topics: batch-write, go, golang, log, mmap, segment, wal, write-ahead-logging
- Language: Go
- Homepage:
- Size: 165 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# wal
[](https://pkg.go.dev/github.com/hslam/wal)
[](https://github.com/hslam/wal/actions)
[](https://codecov.io/gh/hslam/wal)
[](https://goreportcard.com/report/github.com/hslam/wal)
[](https://github.com/hslam/wal/blob/master/LICENSE)
Package wal implements write-ahead logging.
## Feature
* Low memory usage
* Segment
* Batch writes
* Clean/Truncate/Reset
## Get started
### Install
```
go get github.com/hslam/wal
```
### Import
```
import "github.com/hslam/wal"
```
### Usage
#### Example
```go
package main
import (
"fmt"
"github.com/hslam/wal"
"os"
)
func main() {
path := "wal"
os.RemoveAll(path)
w, err := wal.Open(path, &wal.Options{SegmentEntries: 3})
if err != nil {
panic(err)
}
defer w.Close()
// Write
w.Write(1, []byte("Hello World"))
w.Flush()
w.Sync()
// Batch Write
w.Write(2, []byte("Hello WAL"))
w.Write(3, []byte("Hello MH"))
w.Flush()
w.Sync()
data, _ := w.Read(1)
fmt.Println(string(data))
w.Clean(2)
w.Truncate(2)
w.Reset()
}
```
### Output
```
Hello World
```
### License
This package is licensed under a MIT license (Copyright (c) 2020 Meng Huang)
### Author
wal was written by Meng Huang.