file

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CachePath           = "cache"     // cache directory
	CacheFileSuffix     = ".bin"      // cache file suffix
	CacheDirectoryLevel = 2           // cache file deep level if auto generated cache files.
	CacheEmbedExpiry    time.Duration // cache expire time, default is no expire forever.
)

Functions

func GobDecode

func GobDecode(data []byte, to *Item) error

GobDecode Gob decodes a file cache item.

func GobEncode

func GobEncode(data interface{}) ([]byte, error)

func NewFileCache

func NewFileCache() cache.Cache

func PutContents

func PutContents(filename string, content []byte) error

Types

type Cache

type Cache struct {
	CachePath      string
	FileSuffix     string
	DirectoryLevel int
	EmbedExpiry    int
}

func (*Cache) Create

func (c *Cache) Create() error

func (*Cache) Delete

func (c *Cache) Delete(ctx context.Context, key string) error

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, key string) (interface{}, error)

func (*Cache) GetClient

func (c *Cache) GetClient() interface{}

func (*Cache) GetMulti

func (c *Cache) GetMulti(ctx context.Context, keys []string) ([]interface{}, error)

func (*Cache) Put

func (c *Cache) Put(ctx context.Context, key string, val interface{}, timeout time.Duration) error

func (*Cache) Start

func (c *Cache) Start(config string) error

type Item

type Item struct {
	Data       interface{}
	LastAccess time.Time
	Expired    time.Time
}

Jump to

Keyboard shortcuts

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