Documentation
¶
Overview ¶
Package redisutils is a generated GoMock package.
Index ¶
- Constants
- Variables
- func ComposeKey(keys ...string) string
- func WithTx(ctx context.Context, client RedisClient, fn func(pipe redis.Pipeliner) error) error
- type MockRedisClient
- func (m *MockRedisClient) Close() error
- func (m *MockRedisClient) Del(ctx context.Context, keys ...string) *redis.IntCmd
- func (m *MockRedisClient) EXPECT() *MockRedisClientMockRecorder
- func (m *MockRedisClient) Get(ctx context.Context, key string) *redis.StringCmd
- func (m *MockRedisClient) Ping(ctx context.Context) *redis.StatusCmd
- func (m *MockRedisClient) Scan(ctx context.Context, cursor uint64, match string, count int64) *redis.ScanCmd
- func (m *MockRedisClient) Set(ctx context.Context, key string, value any, expiration time.Duration) *redis.StatusCmd
- func (m *MockRedisClient) TxPipelined(ctx context.Context, fn func(redis.Pipeliner) error) ([]redis.Cmder, error)
- func (m *MockRedisClient) Watch(ctx context.Context, fn func(*redis.Tx) error, keys ...string) error
- type MockRedisClientMockRecorder
- func (mr *MockRedisClientMockRecorder) Close() *gomock.Call
- func (mr *MockRedisClientMockRecorder) Del(ctx any, keys ...any) *gomock.Call
- func (mr *MockRedisClientMockRecorder) Get(ctx, key any) *gomock.Call
- func (mr *MockRedisClientMockRecorder) Ping(ctx any) *gomock.Call
- func (mr *MockRedisClientMockRecorder) Scan(ctx, cursor, match, count any) *gomock.Call
- func (mr *MockRedisClientMockRecorder) Set(ctx, key, value, expiration any) *gomock.Call
- func (mr *MockRedisClientMockRecorder) TxPipelined(ctx, fn any) *gomock.Call
- func (mr *MockRedisClientMockRecorder) Watch(ctx, fn any, keys ...any) *gomock.Call
- type RedisClient
- type Storage
Constants ¶
const MAX_RETRIES = 5
Maximum number of retries for a transaction.
Variables ¶
var ErrMaxRetryReachedOut = errors.New("max retries reached out")
Functions ¶
func ComposeKey ¶
ComposeKey concatenates multiple strings into a single Redis key, using ":" as a separator.
Types ¶
type MockRedisClient ¶
type MockRedisClient struct {
// contains filtered or unexported fields
}
MockRedisClient is a mock of RedisClient interface.
func NewMockRedisClient ¶
func NewMockRedisClient(ctrl *gomock.Controller) *MockRedisClient
NewMockRedisClient creates a new mock instance.
func (*MockRedisClient) EXPECT ¶
func (m *MockRedisClient) EXPECT() *MockRedisClientMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockRedisClient) Ping ¶
func (m *MockRedisClient) Ping(ctx context.Context) *redis.StatusCmd
Ping mocks base method.
func (*MockRedisClient) Scan ¶
func (m *MockRedisClient) Scan(ctx context.Context, cursor uint64, match string, count int64) *redis.ScanCmd
Scan mocks base method.
func (*MockRedisClient) Set ¶
func (m *MockRedisClient) Set(ctx context.Context, key string, value any, expiration time.Duration) *redis.StatusCmd
Set mocks base method.
type MockRedisClientMockRecorder ¶
type MockRedisClientMockRecorder struct {
// contains filtered or unexported fields
}
MockRedisClientMockRecorder is the mock recorder for MockRedisClient.
func (*MockRedisClientMockRecorder) Close ¶
func (mr *MockRedisClientMockRecorder) Close() *gomock.Call
Close indicates an expected call of Close.
func (*MockRedisClientMockRecorder) Del ¶
func (mr *MockRedisClientMockRecorder) Del(ctx any, keys ...any) *gomock.Call
Del indicates an expected call of Del.
func (*MockRedisClientMockRecorder) Get ¶
func (mr *MockRedisClientMockRecorder) Get(ctx, key any) *gomock.Call
Get indicates an expected call of Get.
func (*MockRedisClientMockRecorder) Ping ¶
func (mr *MockRedisClientMockRecorder) Ping(ctx any) *gomock.Call
Ping indicates an expected call of Ping.
func (*MockRedisClientMockRecorder) Scan ¶
func (mr *MockRedisClientMockRecorder) Scan(ctx, cursor, match, count any) *gomock.Call
Scan indicates an expected call of Scan.
func (*MockRedisClientMockRecorder) Set ¶
func (mr *MockRedisClientMockRecorder) Set(ctx, key, value, expiration any) *gomock.Call
Set indicates an expected call of Set.
func (*MockRedisClientMockRecorder) TxPipelined ¶
func (mr *MockRedisClientMockRecorder) TxPipelined(ctx, fn any) *gomock.Call
TxPipelined indicates an expected call of TxPipelined.
type RedisClient ¶
type RedisClient interface { Del(ctx context.Context, keys ...string) *redis.IntCmd Get(ctx context.Context, key string) *redis.StringCmd Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd Scan(ctx context.Context, cursor uint64, match string, count int64) *redis.ScanCmd Watch(ctx context.Context, fn func(*redis.Tx) error, keys ...string) error Ping(ctx context.Context) *redis.StatusCmd TxPipelined(ctx context.Context, fn func(redis.Pipeliner) error) ([]redis.Cmder, error) Close() error }
RedisClient defines an interface for interacting with a Redis database. It abstracts common Redis operations to allow flexibility in implementation.
type Storage ¶
type Storage struct { Client RedisClient Client2 *redis.Client }
Storage encapsulates a Redis client, providing methods for initialization and cleanup.
func New ¶
func New(client RedisClient) (*Storage, error)
New initializes a new Storage instance with the given Redis client and verifies the connection.