redis

package module
v0.0.0-...-38e17da Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package redis is a generated GoMock package.

Index

Constants

View Source
const (
	// RedisType represents the storage type as a string value
	RedisType = "redis"
	// RedisTagPattern represents the tag pattern to be used as a key in specified storage
	RedisTagPattern = "gocache_tag_%s"
)

Variables

This section is empty.

Functions

func Init

func Init() cache.Cache

Types

type CacheConfig

type CacheConfig struct {
	Expiration           int         `yaml:"default_expiration"`
	ClientSideExpiration int         `yaml:"client_side_expiration"`
	CleanupInterval      int         `yaml:"cleanup_interval"`
	Redis                RedisConfig `yaml:"redis"`
}

type Config

type Config struct {
	Cache CacheConfig `yaml:"cache"`
}

type MockRedisClientInterface

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

MockRedisClientInterface is a mock of RedisClientInterface interface.

func NewMockRedisClientInterface

func NewMockRedisClientInterface(ctrl *gomock.Controller) *MockRedisClientInterface

NewMockRedisClientInterface creates a new mock instance.

func (*MockRedisClientInterface) Del

Del mocks base method.

func (*MockRedisClientInterface) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockRedisClientInterface) Expire

func (m *MockRedisClientInterface) Expire(ctx context.Context, key string, expiration time.Duration) *redis.BoolCmd

Expire mocks base method.

func (*MockRedisClientInterface) FlushAll

FlushAll mocks base method.

func (*MockRedisClientInterface) Get

Get mocks base method.

func (*MockRedisClientInterface) SAdd

func (m *MockRedisClientInterface) SAdd(ctx context.Context, key string, members ...any) *redis.IntCmd

SAdd mocks base method.

func (*MockRedisClientInterface) SMembers

SMembers mocks base method.

func (*MockRedisClientInterface) Set

func (m *MockRedisClientInterface) Set(ctx context.Context, key string, values any, expiration time.Duration) *redis.StatusCmd

Set mocks base method.

func (*MockRedisClientInterface) TTL

TTL mocks base method.

type MockRedisClientInterfaceMockRecorder

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

MockRedisClientInterfaceMockRecorder is the mock recorder for MockRedisClientInterface.

func (*MockRedisClientInterfaceMockRecorder) Del

func (mr *MockRedisClientInterfaceMockRecorder) Del(ctx any, keys ...any) *gomock.Call

Del indicates an expected call of Del.

func (*MockRedisClientInterfaceMockRecorder) Expire

func (mr *MockRedisClientInterfaceMockRecorder) Expire(ctx, key, expiration any) *gomock.Call

Expire indicates an expected call of Expire.

func (*MockRedisClientInterfaceMockRecorder) FlushAll

FlushAll indicates an expected call of FlushAll.

func (*MockRedisClientInterfaceMockRecorder) Get

Get indicates an expected call of Get.

func (*MockRedisClientInterfaceMockRecorder) SAdd

func (mr *MockRedisClientInterfaceMockRecorder) SAdd(ctx, key any, members ...any) *gomock.Call

SAdd indicates an expected call of SAdd.

func (*MockRedisClientInterfaceMockRecorder) SMembers

func (mr *MockRedisClientInterfaceMockRecorder) SMembers(ctx, key any) *gomock.Call

SMembers indicates an expected call of SMembers.

func (*MockRedisClientInterfaceMockRecorder) Set

func (mr *MockRedisClientInterfaceMockRecorder) Set(ctx, key, values, expiration any) *gomock.Call

Set indicates an expected call of Set.

func (*MockRedisClientInterfaceMockRecorder) TTL

TTL indicates an expected call of TTL.

type RedisClientInterface

type RedisClientInterface interface {
	Get(ctx context.Context, key string) *redis.StringCmd
	TTL(ctx context.Context, key string) *redis.DurationCmd
	Expire(ctx context.Context, key string, expiration time.Duration) *redis.BoolCmd
	Set(ctx context.Context, key string, values any, expiration time.Duration) *redis.StatusCmd
	Del(ctx context.Context, keys ...string) *redis.IntCmd
	FlushAll(ctx context.Context) *redis.StatusCmd
	SAdd(ctx context.Context, key string, members ...any) *redis.IntCmd
	SMembers(ctx context.Context, key string) *redis.StringSliceCmd
}

RedisClientInterface represents a go-redis/redis client

type RedisConfig

type RedisConfig struct {
	Host     string
	Port     int
	Username string
	Password string
}

type RedisStore

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

RedisStore is a store for Redis

func NewRedis

func NewRedis(client RedisClientInterface, options ...store.Option) *RedisStore

NewRedis creates a new store to Redis instance(s)

func (*RedisStore) Clear

func (s *RedisStore) Clear(ctx context.Context) error

Clear resets all data in the store

func (*RedisStore) Delete

func (s *RedisStore) Delete(ctx context.Context, key any) error

Delete removes data from Redis for given key identifier

func (*RedisStore) Get

func (s *RedisStore) Get(ctx context.Context, key any) (any, error)

Get returns data stored from a given key

func (*RedisStore) GetType

func (s *RedisStore) GetType() string

GetType returns the store type

func (*RedisStore) GetWithTTL

func (s *RedisStore) GetWithTTL(ctx context.Context, key any) (any, time.Duration, error)

GetWithTTL returns data stored from a given key and its corresponding TTL

func (*RedisStore) Invalidate

func (s *RedisStore) Invalidate(ctx context.Context, options ...store.InvalidateOption) error

Invalidate invalidates some cache data in Redis for given options

func (*RedisStore) Set

func (s *RedisStore) Set(ctx context.Context, key any, value any, options ...store.Option) error

Set defines data in Redis for given key identifier

Jump to

Keyboard shortcuts

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