apicache

package
v0.126.2 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2023 License: Apache-2.0 Imports: 9 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 {
	SetWithTTL(key string, data []byte, ttl time.Duration)
	Set(key string, data []byte)
	Get(ctx context.Context, key string) (CacheItem, bool)
	Delete(ctx context.Context, key string)
}

type CacheItem

type CacheItem struct {
	Data       []byte
	InsertUnix int64
}

func (*CacheItem) Age

func (c *CacheItem) Age() int64

type InMemoryCache

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

func NewInMemory

func NewInMemory(maxSize int64) (*InMemoryCache, error)

func (*InMemoryCache) Close added in v0.120.0

func (i *InMemoryCache) Close() error

func (*InMemoryCache) Delete

func (i *InMemoryCache) Delete(ctx context.Context, key string)

func (*InMemoryCache) Get

func (i *InMemoryCache) Get(ctx context.Context, key string) (CacheItem, bool)

func (*InMemoryCache) Set

func (i *InMemoryCache) Set(key string, data []byte)

func (*InMemoryCache) SetWithTTL

func (i *InMemoryCache) SetWithTTL(key string, data []byte, ttl time.Duration)

type NoOpCache

type NoOpCache struct{}

func (*NoOpCache) Delete

func (n *NoOpCache) Delete(ctx context.Context, key string)

func (*NoOpCache) Get

func (n *NoOpCache) Get(ctx context.Context, key string) (CacheItem, bool)

func (*NoOpCache) Set

func (n *NoOpCache) Set(key string, data []byte)

func (*NoOpCache) SetWithTTL

func (n *NoOpCache) SetWithTTL(key string, data []byte, ttl time.Duration)

type RedisCache

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

func NewRedis

func NewRedis(connectionString string, log *zap.Logger) (*RedisCache, error)

func (*RedisCache) Delete

func (r *RedisCache) Delete(ctx context.Context, key string)

func (*RedisCache) Get

func (r *RedisCache) Get(ctx context.Context, key string) (CacheItem, bool)

func (*RedisCache) Set

func (r *RedisCache) Set(key string, data []byte)

func (*RedisCache) SetWithTTL

func (r *RedisCache) SetWithTTL(key string, data []byte, ttl time.Duration)

Jump to

Keyboard shortcuts

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