driver

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache[K comparable, V any] interface {
	Has(ctx context.Context, key K) bool
	Get(ctx context.Context, k K) (V, bool)
	All(ctx context.Context) map[K]V
	Set(ctx context.Context, key K, value V) bool
	Delete(ctx context.Context, key K) bool
	Clear(ctx context.Context) bool
}

type MemoryCache

type MemoryCache[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewMemoryCache

func NewMemoryCache[K comparable, V any]() MemoryCache[K, V]

func (MemoryCache[K, V]) All

func (m MemoryCache[K, V]) All(_ context.Context) map[K]V

func (MemoryCache[K, V]) Clear

func (m MemoryCache[K, V]) Clear(_ context.Context) bool

func (MemoryCache[K, V]) Delete

func (m MemoryCache[K, V]) Delete(ctx context.Context, key K) bool

func (MemoryCache[K, V]) Get

func (m MemoryCache[K, V]) Get(_ context.Context, key K) (V, bool)

func (MemoryCache[K, V]) Has

func (m MemoryCache[K, V]) Has(_ context.Context, key K) bool

func (MemoryCache[K, V]) Set

func (m MemoryCache[K, V]) Set(ctx context.Context, key K, value V) bool

type RedisCache

type RedisCache[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewRedisCacheDriver

func NewRedisCacheDriver[K comparable, V any](redisKey string, redisClient *redis.Client) *RedisCache[K, V]

func (*RedisCache[K, V]) All

func (r *RedisCache[K, V]) All(ctx context.Context) map[K]V

func (*RedisCache[K, V]) Clear

func (r *RedisCache[K, V]) Clear(ctx context.Context) bool

func (*RedisCache[K, V]) Delete

func (r *RedisCache[K, V]) Delete(ctx context.Context, key K) bool

func (*RedisCache[K, V]) Get

func (r *RedisCache[K, V]) Get(ctx context.Context, key K) (V, bool)

func (*RedisCache[K, V]) Has

func (r *RedisCache[K, V]) Has(ctx context.Context, key K) bool

func (*RedisCache[K, V]) Set

func (r *RedisCache[K, V]) Set(ctx context.Context, key K, value V) bool

Jump to

Keyboard shortcuts

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