teacache

package
v0.1.72 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2019 License: MIT Imports: 28 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 FindType added in v0.1.2

func FindType(typeCode string) maps.Map

查找类型信息

func FindTypeName added in v0.1.2

func FindTypeName(typeCode string) string

查找类型名称

func ProcessAfterRequest

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

请求之后处理

func ProcessBeforeRequest

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

请求之前处理

func ResetCachePolicyManager added in v0.1.2

func ResetCachePolicyManager(filename string)

重置管理器

Types

type FileManager

type FileManager struct {
	Manager

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

文件缓存管理器

func NewFileManager

func NewFileManager() *FileManager

func (*FileManager) Clean added in v0.1.2

func (this *FileManager) Clean() error

清理

func (*FileManager) Close added in v0.1.2

func (this *FileManager) Close() error

func (*FileManager) Delete added in v0.1.2

func (this *FileManager) Delete(key string) error

删除

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) Stat added in v0.1.2

func (this *FileManager) Stat() (size int64, countKeys int, err error)

统计

func (*FileManager) Write

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

写入

type Item

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

缓存条目

func NewItem added in v0.1.2

func NewItem() *Item

获取新对象

func (*Item) Decode

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

func (*Item) Encode

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

type LevelDBManager added in v0.1.2

type LevelDBManager struct {
	Manager

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

Leveldb缓存管理器

func NewLevelDBManager added in v0.1.2

func NewLevelDBManager() *LevelDBManager

func (*LevelDBManager) Clean added in v0.1.2

func (this *LevelDBManager) Clean() error

清理

func (*LevelDBManager) CleanExpired added in v0.1.2

func (this *LevelDBManager) CleanExpired() error

func (*LevelDBManager) Close added in v0.1.2

func (this *LevelDBManager) Close() error

关闭

func (*LevelDBManager) Delete added in v0.1.2

func (this *LevelDBManager) Delete(key string) error

删除

func (*LevelDBManager) Read added in v0.1.2

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

func (*LevelDBManager) SetOptions added in v0.1.2

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

func (*LevelDBManager) Stat added in v0.1.2

func (this *LevelDBManager) Stat() (size int64, countKeys int, err error)

统计

func (*LevelDBManager) Write added in v0.1.2

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

type Manager added in v0.1.2

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

func (*Manager) Id added in v0.1.2

func (this *Manager) Id() string

获取ID

func (*Manager) SetId added in v0.1.2

func (this *Manager) SetId(id string)

设置ID

type ManagerInterface

type ManagerInterface interface {
	// 设置ID
	SetId(id string)

	// 写入
	Write(key string, data []byte) error

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

	// 删除
	Delete(key string) error

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

	// 统计
	Stat() (size int64, countKeys int, err error)

	// 清理
	Clean() error

	// 关闭
	Close() error
}

缓存管理接口

func FindCachePolicyManager added in v0.1.2

func FindCachePolicyManager(filename string) ManagerInterface

获取管理器

func NewManagerFromConfig

func NewManagerFromConfig(config *shared.CachePolicy) ManagerInterface

获取新的管理对象

type MemoryManager

type MemoryManager struct {
	Manager

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

内存缓存管理器

func NewMemoryManager

func NewMemoryManager() *MemoryManager

func (*MemoryManager) Clean added in v0.1.2

func (this *MemoryManager) Clean() error

清理

func (*MemoryManager) Close added in v0.1.2

func (this *MemoryManager) Close() error

关闭

func (*MemoryManager) Delete added in v0.1.2

func (this *MemoryManager) Delete(key string) error

删除

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) Stat added in v0.1.2

func (this *MemoryManager) Stat() (size int64, countKeys int, err error)

统计

func (*MemoryManager) Write

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

type RedisManager

type RedisManager struct {
	Manager

	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) Clean added in v0.1.2

func (this *RedisManager) Clean() error

清理

func (*RedisManager) Close added in v0.1.2

func (this *RedisManager) Close() error

关闭

func (*RedisManager) Delete added in v0.1.2

func (this *RedisManager) Delete(key string) error

删除

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) Stat added in v0.1.2

func (this *RedisManager) Stat() (size int64, countKeys int, err error)

统计

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