Documentation ¶
Overview ¶
Example ¶
dir, err := os.MkdirTemp("", "testdir") if err != nil { panic(err) } log, err := Open(dir) if err != nil { panic(err) } i1, _ := log.Write([]byte("data1")) i2, _ := log.Write([]byte("data2")) _ = log.WriteAt(Index(100), []byte("data3")) data1, _ := log.Read(i1) fmt.Println(string(data1)) data3, _ := log.Read(Index(100)) fmt.Println(string(data3)) // delete logs on memory if err := log.Delete(i1, i2); err != nil { panic(err) } // compaction of deleted logs to free disk space if err := log.Compact(); err != nil { panic(err) }
Output: data1 data3
Index ¶
- Constants
- Variables
- type Index
- type Log
- func (l *Log) Close() error
- func (l *Log) Compact() error
- func (l *Log) Delete(idxs ...Index) error
- func (l *Log) LastIndex() Index
- func (l *Log) Len() int
- func (l *Log) Read(idx Index) ([]byte, error)
- func (l *Log) ReclaimableSpace() uint64
- func (l *Log) Sync() error
- func (l *Log) Write(data []byte) (Index, error)
- func (l *Log) WriteAt(idx Index, data []byte) error
- type OptionFunc
Examples ¶
Constants ¶
View Source
const ( AppName string = "wal" Version string = "1.0.0" )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
func (*Log) ReclaimableSpace ¶
type OptionFunc ¶
type OptionFunc func(*logOpt)
func WithSync ¶
func WithSync(enable bool) OptionFunc
func WithWriteBufferSize ¶
func WithWriteBufferSize(size int) OptionFunc
Click to show internal directories.
Click to hide internal directories.