db

package
v0.0.0-...-de7d321 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DB_LEVEL = "leveldb"
	DB_REDIS = "redis"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Write(key string, value []byte, duration time.Duration) error
	Get(key string) ([]byte, error)
	IsCached(key string) bool
	Delete(key string) error
	Close() error
	DeleteExpired()
}

func GetCache

func GetCache() Cache

func NewLevelDbCache

func NewLevelDbCache(filepath string) (Cache, error)

func NewNonCache

func NewNonCache() Cache

func NewRedisCache

func NewRedisCache(addr string, password string, db int) (Cache, error)

type CacheTime

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

type LevelCache

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

func (*LevelCache) Close

func (level *LevelCache) Close() error

func (*LevelCache) Delete

func (level *LevelCache) Delete(key string) error

func (*LevelCache) DeleteExpired

func (level *LevelCache) DeleteExpired()

func (*LevelCache) Get

func (level *LevelCache) Get(key string) ([]byte, error)

func (*LevelCache) IsCached

func (level *LevelCache) IsCached(key string) bool

func (*LevelCache) Write

func (level *LevelCache) Write(key string, value []byte, d time.Duration) error

type NonCache

type NonCache struct{}

func (*NonCache) Close

func (non *NonCache) Close() error

func (*NonCache) Delete

func (non *NonCache) Delete(key string) error

func (*NonCache) DeleteExpired

func (non *NonCache) DeleteExpired()

func (*NonCache) Get

func (non *NonCache) Get(key string) ([]byte, error)

func (*NonCache) IsCached

func (non *NonCache) IsCached(key string) bool

func (*NonCache) Write

func (non *NonCache) Write(key string, value []byte, d time.Duration) error

type RedisCache

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

func (*RedisCache) Close

func (r *RedisCache) Close() error

func (*RedisCache) Delete

func (r *RedisCache) Delete(key string) error

func (*RedisCache) DeleteExpired

func (r *RedisCache) DeleteExpired()

func (*RedisCache) Get

func (r *RedisCache) Get(key string) ([]byte, error)

func (*RedisCache) IsCached

func (r *RedisCache) IsCached(key string) bool

func (*RedisCache) Write

func (r *RedisCache) Write(key string, value []byte, d time.Duration) error

Jump to

Keyboard shortcuts

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