recordstore

package
v0.0.0-...-e1de4b4 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrRecordNotFound キーをもとにストアを探したがレコードがなかった
	ErrRecordNotFound = errors.New("record not found")
)

Functions

func Close

func Close()

Close DBをクローズする

func DeleteKeysWithSize

func DeleteKeysWithSize(size int64) error

DeleteKeysWithSize size分だけキーを適当に消す

func GenerateCacheFileName

func GenerateCacheFileName() string

GenerateCacheFileName UUIDを返すだけ

func GenerateKey

func GenerateKey(bucketName string, blobName string) string

GenerateKey bucketNameとblobNameからKVSで使うkeyを作る

func GetCacheFileNames

func GetCacheFileNames(size int64) (set.Set, error)

GetCacheFileNames 指定サイズ分のcache file nameを返す size 0なら全て

func GetKeys

func GetKeys(size int64) (set.Set, error)

GetKeys 指定サイズ分のキーをiterateして返す size 0なら全て

func RunGC

func RunGC() error

RunGC badgerのGCを走らせる

func SetRecord

func SetRecord(key string, record *Record) error

SetRecord KVSにRecordをセットする

Types

type Record

type Record struct {
	BlobName        string    `json:"blob_name"`       // GCSのbucket内での名前
	CacheFileName   string    `json:"cache_file_name"` // キャッシュのファイル名 UUID
	Size            int64     `json:"size"`            // ファイルサイズ
	ContentType     string    `json:"content_type"`    // ContentType
	LastRequestedAt time.Time `json:"last_requested_at"`
	CreatedAt       time.Time `json:"created_at"`
}

Record storeに保存するデータ

func GetRecord

func GetRecord(key string) (*Record, error)

GetRecord KVSからRecordを探して返す、なければnilとerrorを返す

func (*Record) GetPath

func (r *Record) GetPath() string

GetPath キャッシュの実体のパスを返す

func (*Record) MarshalBinary

func (r *Record) MarshalBinary() ([]byte, error)

MarshalBinary Record -> json

func (*Record) UnmarshalBinary

func (r *Record) UnmarshalBinary(data []byte) error

UnmarshalBinary json -> Record

Jump to

Keyboard shortcuts

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