Skip to content

一个golang实现的能够对写文件进行缓存写操作的包

License

Notifications You must be signed in to change notification settings

zr-hebo/util-cache

Repository files navigation

一个golang实现的处理缓存的包

bufferedwriter

写文件时,为了提高性能,写的内容先放在缓存中,等缓存满了的时候再写入到文件。

Install

Use go get to install this package:
$ go get github.com/zr-hebo/util-cache

Usage

import (
	cu "github.com/zr-hebo/util-cache"
)

// 创建带缓存的Writer,file是打开的文件,bufferSize是缓存的大小
writer, err := cu.NewBufferedWriter(file, bufferSize)
if err != nil {
	return
}

// 将byte数组写入writer	
if err = writer.Write(rowData); err != nil {
	return
}

// 等待缓存中的数据全部写入文件
if err = writer.WaitClean(); err != nil {
	return
}

About

一个golang实现的能够对写文件进行缓存写操作的包

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages