store

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 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 InMemoryStore

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

func (*InMemoryStore) Get

func (c *InMemoryStore) Get(_ context.Context, key string) (interface{}, time.Duration, error)

func (*InMemoryStore) Increment

func (c *InMemoryStore) Increment(_ context.Context, key string) (int64, time.Duration, error)

func (*InMemoryStore) Remove

func (c *InMemoryStore) Remove(_ context.Context, key string) error

func (*InMemoryStore) Set

func (c *InMemoryStore) Set(_ context.Context, key string, value interface{}) error

type RedisClient

type RedisClient interface {
	Ping(ctx context.Context) *redis.StatusCmd
	Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd
	Get(ctx context.Context, key string) *redis.StringCmd
	TTL(ctx context.Context, key string) *redis.DurationCmd
	Del(ctx context.Context, keys ...string) *redis.IntCmd
	Incr(ctx context.Context, key string) *redis.IntCmd
	Expire(ctx context.Context, key string, expiration time.Duration) *redis.BoolCmd
}

func NewRedisClient

func NewRedisClient(addr string, clusterMode bool) RedisClient

type RedisStore

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

func (*RedisStore) Get

func (c *RedisStore) Get(ctx context.Context, key string) (interface{}, time.Duration, error)

func (*RedisStore) Increment

func (c *RedisStore) Increment(ctx context.Context, key string) (int64, time.Duration, error)

func (*RedisStore) Remove

func (c *RedisStore) Remove(ctx context.Context, key string) error

func (*RedisStore) Set

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

type Store

type Store interface {
	Set(ctx context.Context, key string, value interface{}) error
	Get(ctx context.Context, key string) (interface{}, time.Duration, error)
	Increment(ctx context.Context, key string) (int64, time.Duration, error)
	Remove(ctx context.Context, key string) error
}

func NewInMemoryStore

func NewInMemoryStore(ttl time.Duration) Store

func NewRedisStore

func NewRedisStore(ttl time.Duration, addr string, clusterMode bool) Store

Jump to

Keyboard shortcuts

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