cache

package
v0.0.0-...-bc9ab7c Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2017 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

用文件形式存储远程资源

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DumpCacheObject

func DumpCacheObject(w io.Writer, oc *CacheObject) error

Types

type CacheObject

type CacheObject struct {
	Source    string    // 源地址
	Length    uint64    // 长度
	MD5Hash   [16]byte  // 内容 hash 值
	CreatedAt time.Time // 缓存创建的时间
	Object    []byte    // 缓存的内容
}

func LoadCacheObject

func LoadCacheObject(r io.Reader) (*CacheObject, error)

type FileStorage

type FileStorage struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewFileStorage

func NewFileStorage(path string) *FileStorage

func (*FileStorage) Delete

func (fs *FileStorage) Delete(key string) error

func (*FileStorage) Get

func (fs *FileStorage) Get(key string) (*CacheObject, error)

func (*FileStorage) Set

func (fs *FileStorage) Set(key string, oc *CacheObject) error

type Storager

type Storager interface {
	Get(key string) (*CacheObject, error)
	Set(key string, oc *CacheObject) error
	Delete(key string) error
}

Jump to

Keyboard shortcuts

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