adapters

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: Apache-2.0, MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMemcachedDriver

func NewMemcachedDriver(client *memcache.Client) (Cache, LockFactory)

func NewRedigoDriver added in v1.1.0

func NewRedigoDriver(pool *redis.Pool) (Cache, LockFactory)

func NewRedisDriver

func NewRedisDriver(client *redis.Client) (Cache, LockFactory)

Types

type Cache

type Cache interface {
	// Get returns the value for the specified key if it is present in the cache.
	Get(ctx context.Context, key string) ([]byte, error)
	// Set inserts or updates the specified key-value pair with an expiration time.
	Set(ctx context.Context, key string, value []byte, expiry time.Duration) error
}

Cache

type DistributedLock

type DistributedLock interface {
	Lock() error
	Unlock() error
}

DistributedLock

type LockFactory

type LockFactory func(key string, duration time.Duration) DistributedLock

LockFactory

func MemcacheLockFactory

func MemcacheLockFactory(cache *memcache.Client) LockFactory

func RedisLockFactory

func RedisLockFactory(locker *redsync.Redsync) LockFactory

type Memcached

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

func (*Memcached) Get

func (m *Memcached) Get(_ context.Context, key string) ([]byte, error)

Get returns the value for the specified key if it is present in the cache.

func (*Memcached) Set

func (m *Memcached) Set(_ context.Context, key string, value []byte, expiry time.Duration) error

Set inserts or updates the specified key-value pair with an expiration time.

type Redigo added in v1.1.0

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

func (*Redigo) Get added in v1.1.0

func (r *Redigo) Get(ctx context.Context, key string) (value []byte, err error)

Get returns the value for the specified key if it is present in the cache.

func (*Redigo) Set added in v1.1.0

func (r *Redigo) Set(ctx context.Context, key string, value []byte, expiry time.Duration) error

Set inserts or updates the specified key-value pair with an expiration time.

type Redis

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

func (*Redis) Get

func (r *Redis) Get(ctx context.Context, key string) ([]byte, error)

Get returns the value for the specified key if it is present in the cache.

func (*Redis) Set

func (r *Redis) Set(ctx context.Context, key string, value []byte, expiry time.Duration) error

Set inserts or updates the specified key-value pair with an expiration time.

Jump to

Keyboard shortcuts

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