cache

package
v1.0.1-0...-5011f7a Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AvatarHash

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

func NewAvatarHash

func NewAvatarHash() *AvatarHash

func (*AvatarHash) Email

func (c *AvatarHash) Email(id int) string

根据 ID 获取 Email。 如果不存在,返回空。

func (*AvatarHash) ID

func (c *AvatarHash) ID(email string) int

type AvatarHasher

type AvatarHasher interface {
	ID(email string) int
	Email(id int) string
}

type RelativeCacheKeys

type RelativeCacheKeys[PrimaryKey, SecondStageKey comparable] struct {
	// contains filtered or unexported fields
}

func NewRelativeCacheKeys

func NewRelativeCacheKeys[PrimaryKey, SecondStageKey comparable]() *RelativeCacheKeys[PrimaryKey, SecondStageKey]

func (*RelativeCacheKeys[PrimaryKey, SecondStageKey]) Append

func (c *RelativeCacheKeys[PrimaryKey, SecondStageKey]) Append(key PrimaryKey, second SecondStageKey)

func (*RelativeCacheKeys[PrimaryKey, SecondStageKey]) Delete

func (c *RelativeCacheKeys[PrimaryKey, SecondStageKey]) Delete(key PrimaryKey, fn func(second SecondStageKey))

type TmpFiles

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

func NewTmpFiles

func NewTmpFiles(dir string, keep time.Duration) *TmpFiles

TODO 支持内存文件系统以方便测试。

func (*TmpFiles) Cache

func (t *TmpFiles) Cache(key string, r io.ReadCloser) error

func (*TmpFiles) GetOrLoad

func (t *TmpFiles) GetOrLoad(key string, loader func(key string) (io.ReadCloser, error)) (io.ReadCloser, error)

NOTE loader 是串行调用的。

Jump to

Keyboard shortcuts

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