storage

package
v0.0.0-...-1e5e0da Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package storage 数据真实存储操作

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler func(SeekStartIndex int64, SeekStart int64, SeekLast int)

Handler 存储回调

索引最终存储在文件中的起始位置

value最终存储在文件中的起始位置

value最终存储在文件中的持续长度

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

Storage 文件存储服务

func Obtain

func Obtain() *Storage

Obtain 取得Storage对象

func (*Storage) Store

func (s *Storage) Store(databaseID, formID string, value interface{}, writes []*Write) error

Store 存储具体内容

databaseID 数据库唯一id

formID 表唯一id

key 唯一key

value 存储具体内容

valid 存储有效性,如无效则表示该记录不可用,即删除

writes 索引即将写入的参考坐标数组

return []*Written 返回完成索引写入后的结果数组

func (*Storage) Take

func (s *Storage) Take(filePath string, seekStart int64, seekLast int) (interface{}, error)

Take 取出具体内容

filePath 从该路径文件中读取

seekStart value最终存储在文件中的起始位置

seekLast value最终存储在文件中的持续长度

return Read 返回数据读取结果

type Write

type Write struct {
	IndexID           string  // 索引ID
	FormIndexFilePath string  // 索引文件所在路径
	MD516Key          string  // 索引对应字符串key
	HashKey           uint64  // put hash hashKey
	SeekStartIndex    int64   // 上一索引最终存储在文件中的起始位置
	Version           int     // 当前索引数据版本号
	Handler           Handler // 存储回调mu         sync.Mutex
}

Write 索引即将写入的参考坐标

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL