cache

package
v1.1.2-rc3 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2024 License: MIT Imports: 5 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 struct {
	// contains filtered or unexported fields
}

func NewCache

func NewCache(prefix string, store Store) *Cache

Create a new cache

func (*Cache) Get

func (cache *Cache) Get(ctx context.Context, key string, value any) error

func (*Cache) Set

func (cache *Cache) Set(ctx context.Context, key string, value any, ttl time.Duration) error

type MemoryStore

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

func NewMemoryStore

func NewMemoryStore() *MemoryStore

func (*MemoryStore) Get

func (s *MemoryStore) Get(ctx context.Context, key string, value any) error

func (*MemoryStore) Has

func (s *MemoryStore) Has(ctx context.Context, key string) bool

func (*MemoryStore) Set

func (s *MemoryStore) Set(ctx context.Context, key string, value any, ttl time.Duration) error

type RedisStore

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

func NewRedisStore

func NewRedisStore(options *cache.Options) *RedisStore

func (*RedisStore) Get

func (s *RedisStore) Get(ctx context.Context, key string, value interface{}) error

func (*RedisStore) Has

func (s *RedisStore) Has(ctx context.Context, key string) bool

func (*RedisStore) Set

func (s *RedisStore) Set(ctx context.Context, key string, value any, ttl time.Duration) error

type Store

type Store interface {
	// Set an item in the store.
	Set(ctx context.Context, key string, value any, TTL time.Duration) error

	// Get an item from the store.
	// returns an error if key is not found or there is other problems.
	Get(ctx context.Context, key string, value any) error

	// Check if a key exist in the store.
	Has(ctx context.Context, key string) bool
}

Interface to a cache storage.

Jump to

Keyboard shortcuts

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