storage

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ZoneHuanan   = "Huanan"
	ZoneHuabei   = "Huabei"
	ZoneHuadong  = "Huadong"
	ZoneBeimei   = "Beimei"
	ZoneXinjiapo = "Xinjiapo"

	// TokenLifetime 上传凭证有效期,十分钟
	TokenLifetime = 600
)

Variables

View Source
var (
	ErrBadParamsError  = errors.New("参数异常")
	ErrUploadFailError = errors.New("数据上传失败")
)

Functions

This section is empty.

Types

type BoltBucket

type BoltBucket struct {
	*BoltStorage
	// contains filtered or unexported fields
}

func (*BoltBucket) All

func (bb *BoltBucket) All() (map[string][]byte, error)

All 获取指定 Bucket 中所有数据

func (*BoltBucket) BatchUpdate

func (bb *BoltBucket) BatchUpdate(key, value []byte) error

Update 数据, 当使用多线程/协程处理时,用此方法

func (*BoltBucket) Delete

func (bb *BoltBucket) Delete(key []byte) error

Delete 删除指定 KEY-VALUE 数据

func (*BoltBucket) Get

func (bb *BoltBucket) Get(key []byte) ([]byte, error)

Get 在指定 Bucket 中查询相关值

func (*BoltBucket) Set

func (bb *BoltBucket) Set(key, value []byte) error

Set 在指定 Bucket 中存储数据

type BoltStorage

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

func NewBolt

func NewBolt(dbPath string) (*BoltStorage, error)

func (*BoltStorage) All

func (b *BoltStorage) All() (map[string][]byte, error)

func (*BoltStorage) BatchUpdate

func (b *BoltStorage) BatchUpdate(key, value []byte) error

func (*BoltStorage) Close

func (b *BoltStorage) Close()

func (*BoltStorage) Delete

func (b *BoltStorage) Delete(key []byte) error

func (*BoltStorage) DeleteBucket

func (b *BoltStorage) DeleteBucket(name string) error

DeleteBucket 删除指定 Bucket

func (*BoltStorage) Get

func (b *BoltStorage) Get(key []byte) ([]byte, error)

func (*BoltStorage) NewBucket

func (b *BoltStorage) NewBucket(name string) (*BoltBucket, error)

NewBucket 创建一个新的 Bucket

func (*BoltStorage) Set

func (b *BoltStorage) Set(key, value []byte) error

func (*BoltStorage) Sync

func (b *BoltStorage) Sync() error

Sync 数据刷盘

type QiniuOptions

type QiniuOptions struct {
	SecretKey     string `mapstructure:"secret_key" yaml:"secret_key"`
	AccessKey     string `mapstructure:"access_key" yaml:"access_key"`
	BucketName    string `mapstructure:"bucket_name" yaml:"bucket_name"`
	Domain        string `mapstructure:"domain" yaml:"domain"`
	UseCdnDomains bool   `mapstructure:"use_cdn_domains" yaml:"use_cdn_domains"`
	UseHTTPS      bool   `mapstructure:"use_https" yaml:"use_https"`
	Zone          string `mapstructure:"zone" yaml:"zone"`
	Lifetime      int    `mapstructure:"lifetime" yaml:"lifetime"`
}

type QiniuService

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

func NewQiniuService

func NewQiniuService(opts QiniuOptions) (*QiniuService, error)

NewStorageService 新建 七牛云上传服务

func (*QiniuService) PrivateURL

func (ss *QiniuService) PrivateURL(ctx context.Context, fileName string, lifetime int) string

PrivateURL 获取私有空间文件下载连接

func (*QiniuService) PublicURL

func (ss *QiniuService) PublicURL(ctx context.Context, fileName string) string

PublicURL 获取从公共空间下载连接

func (*QiniuService) Upload

func (ss *QiniuService) Upload(ctx context.Context, key string, reader io.Reader, size int) error

Upload 上传文件

Jump to

Keyboard shortcuts

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