An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          

# wal
[![PkgGoDev](https://pkg.go.dev/badge/github.com/hslam/wal)](https://pkg.go.dev/github.com/hslam/wal)
[![Build Status](https://github.com/hslam/wal/workflows/build/badge.svg)](https://github.com/hslam/wal/actions)
[![codecov](https://codecov.io/gh/hslam/wal/branch/master/graph/badge.svg)](https://codecov.io/gh/hslam/wal)
[![Go Report Card](https://goreportcard.com/badge/github.com/hslam/wal?v=7e100)](https://goreportcard.com/report/github.com/hslam/wal)
[![LICENSE](https://img.shields.io/github/license/hslam/wal.svg?style=flat-square)](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.