teacache

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2019 License: MIT Imports: 21 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("cache not found")

Functions

func AllCacheTypes

func AllCacheTypes() []maps.Map

所有的缓存配置

func ProcessAfterRequest

func ProcessAfterRequest(req *teaproxy.Request, writer *teaproxy.ResponseWriter) bool

func ProcessBeforeRequest

func ProcessBeforeRequest(req *teaproxy.Request, writer *teaproxy.ResponseWriter) bool

func TypeName

func TypeName(typeCode string) string

类型名称

Types

type FileManager

type FileManager struct {
	Capacity float64       // 容量
	Life     time.Duration // 有效期
	// contains filtered or unexported fields
}

文件缓存管理器

func NewFileManager

func NewFileManager() *FileManager

func (*FileManager) Read

func (this *FileManager) Read(key string) (data []byte, err error)

func (*FileManager) SetOptions

func (this *FileManager) SetOptions(options map[string]interface{})

func (*FileManager) Write

func (this *FileManager) Write(key string, data []byte) error

type Item

type Item struct {
	Header []byte
	Body   []byte
}

func (*Item) Decode

func (this *Item) Decode(data []byte)

func (*Item) Encode

func (this *Item) Encode() (data []byte)

type ManagerInterface

type ManagerInterface interface {
	// 写入
	Write(key string, data []byte) error

	// 读取
	Read(key string) (data []byte, err error)

	// 设置选项
	SetOptions(options map[string]interface{})
}

缓存管理接口

func NewManagerFromConfig

func NewManagerFromConfig(config *shared.CachePolicy) ManagerInterface

获取新的管理对象

type MemoryManager

type MemoryManager struct {
	Capacity float64       // 容量
	Life     time.Duration // 有效期
	// contains filtered or unexported fields
}

内存缓存管理器

func NewMemoryManager

func NewMemoryManager() *MemoryManager

func (*MemoryManager) Read

func (this *MemoryManager) Read(key string) (data []byte, err error)

func (*MemoryManager) SetOptions

func (this *MemoryManager) SetOptions(options map[string]interface{})

func (*MemoryManager) Write

func (this *MemoryManager) Write(key string, data []byte) error

type RedisManager

type RedisManager struct {
	Capacity float64       // 容量
	Life     time.Duration // 有效期

	Network  string
	Host     string
	Port     int
	Password string
	Sock     string
	// contains filtered or unexported fields
}

内存缓存管理器

func NewRedisManager

func NewRedisManager() *RedisManager

func (*RedisManager) Read

func (this *RedisManager) Read(key string) (data []byte, err error)

func (*RedisManager) SetOptions

func (this *RedisManager) SetOptions(options map[string]interface{})

func (*RedisManager) Write

func (this *RedisManager) Write(key string, data []byte) error

Jump to

Keyboard shortcuts

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