cache

package
v0.1.32 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// 是否开启压缩。压缩后能减小数据量,但压缩过程会耗时。
	// 如果原数据长度很长,压缩耗时要比查询耗时低得多,此时开启压缩功能是最佳选择。
	// 但如果原数据长度较短,压缩或不压缩,整体耗时区别不大。
	// 是否开启压缩,需要自行测试抉择。
	Compressed(yes bool)
	// 初始化,用来迁移数据库 / 表,和一些与数据库有关的前期准备工作
	Init() error
	// 当前请求是否已缓存过,如果缓存过,则返回缓存中的响应
	IsCached(key string) ([]byte, bool)
	// 将没有缓存过的请求保存到缓存中
	Cache(key string, val []byte) error
	// 清除全部缓存
	Clear() error
}

type CacheModel

type CacheModel struct {
	Key   string `gorm:"primaryKey"`
	Value []byte
}

func (CacheModel) TableName

func (CacheModel) TableName() string

type MySQLCache

type MySQLCache struct {
	Host, Port, Database, Username, Password string
	// contains filtered or unexported fields
}

func (*MySQLCache) Cache

func (mc *MySQLCache) Cache(key string, val []byte) error

func (*MySQLCache) Clear

func (mc *MySQLCache) Clear() error

func (*MySQLCache) Compressed

func (mc *MySQLCache) Compressed(yes bool)

func (*MySQLCache) Init

func (mc *MySQLCache) Init() error

func (*MySQLCache) IsCached

func (mc *MySQLCache) IsCached(key string) ([]byte, bool)

type PostgreSQLCache

type PostgreSQLCache struct {
	Host, Port, Database, Username, Password, SSLMode, TimeZone string
	// contains filtered or unexported fields
}

func (*PostgreSQLCache) Cache

func (pc *PostgreSQLCache) Cache(key string, val []byte) error

func (*PostgreSQLCache) Clear

func (pc *PostgreSQLCache) Clear() error

func (*PostgreSQLCache) Compressed

func (pc *PostgreSQLCache) Compressed(yes bool)

func (*PostgreSQLCache) Init

func (pc *PostgreSQLCache) Init() error

func (*PostgreSQLCache) IsCached

func (pc *PostgreSQLCache) IsCached(key string) ([]byte, bool)

type RedisCache

type RedisCache struct {
	Addr, Password string
	DB             int
	// contains filtered or unexported fields
}

func (*RedisCache) Cache

func (rc *RedisCache) Cache(key string, val []byte) error

func (*RedisCache) Clear

func (rc *RedisCache) Clear() error

func (*RedisCache) Compressed

func (rc *RedisCache) Compressed(yes bool)

func (*RedisCache) Init

func (rc *RedisCache) Init() error

func (*RedisCache) IsCached

func (rc *RedisCache) IsCached(key string) ([]byte, bool)

type SQLiteCache

type SQLiteCache struct {
	URI string
	// contains filtered or unexported fields
}

func (*SQLiteCache) Cache

func (sc *SQLiteCache) Cache(key string, val []byte) error

func (*SQLiteCache) Clear

func (sc *SQLiteCache) Clear() error

func (*SQLiteCache) Compressed

func (sc *SQLiteCache) Compressed(yes bool)

func (*SQLiteCache) Init

func (sc *SQLiteCache) Init() error

func (*SQLiteCache) IsCached

func (sc *SQLiteCache) IsCached(key string) ([]byte, bool)

Jump to

Keyboard shortcuts

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