cache

package
v0.0.0-...-967fbc8 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemoryCache

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

func NewMemoryCache

func NewMemoryCache(size int) (*MemoryCache, error)

func (*MemoryCache) Close

func (c *MemoryCache) Close() error

Always returns nil.

func (*MemoryCache) Collectors

func (c *MemoryCache) Collectors() []prometheus.Collector

func (*MemoryCache) Get

func (c *MemoryCache) Get(k []byte) (v []byte, t Times)

func (*MemoryCache) Store

func (c *MemoryCache) Store(k []byte, v []byte, t Times, setNX bool)

type RedisCache

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

func NewRedisCache

func NewRedisCache(u string, logger *zerolog.Logger) (*RedisCache, error)

func (*RedisCache) Close

func (c *RedisCache) Close() error

Always returns nil.

func (*RedisCache) Collectors

func (c *RedisCache) Collectors() []prometheus.Collector

func (*RedisCache) Get

func (c *RedisCache) Get(ctx context.Context, k []byte) ([]byte, Times)

Get dose not return error. All errors (of broking/invalid stored data, connection lost, etc.) will be logged.

func (*RedisCache) Ping

func (c *RedisCache) Ping(ctx context.Context) (time.Duration, error)

func (*RedisCache) Store

func (c *RedisCache) Store(k []byte, v []byte, t Times, setNX bool)

Store v in to redis. Errors will be logged to the RedisCache logger.

type Times

type Times struct {
	StoredAtUnix      int64 // Info only
	ExpireAtUnix      int64 // Info only
	CacheExpireAtUnix int64
}

Jump to

Keyboard shortcuts

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