Documentation ¶
Index ¶
- func BatchGetCache[T any, K comparable](ctx context.Context, rcClient *rockscache.Client, expire time.Duration, ...) ([]T, error)
- func GetCache[T any](ctx context.Context, rcClient *rockscache.Client, key string, ...) (T, error)
- func GetRocksCacheOptions() rockscache.Options
- func ProcessKeysBySlot(ctx context.Context, redisClient redis.UniversalClient, keys []string, ...) error
- type BatchDeleter
- type BatchDeleterRedis
- type Option
- type RedisShardManagerConfig
- type ShardManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BatchGetCache ¶
func GetRocksCacheOptions ¶
func GetRocksCacheOptions() rockscache.Options
GetRocksCacheOptions returns the default configuration options for RocksCache.
func ProcessKeysBySlot ¶
func ProcessKeysBySlot( ctx context.Context, redisClient redis.UniversalClient, keys []string, processFunc func(ctx context.Context, slot int64, keys []string) error, opts ...Option, ) error
ProcessKeysBySlot groups keys by their Redis cluster hash slots and processes them using the provided function.
Types ¶
type BatchDeleter ¶
type BatchDeleter interface { //ChainExecDel method is used for chain calls and must call Clone to prevent memory pollution. ChainExecDel(ctx context.Context) error //ExecDelWithKeys method directly takes keys for deletion. ExecDelWithKeys(ctx context.Context, keys []string) error //Clone method creates a copy of the BatchDeleter to avoid modifying the original object. Clone() BatchDeleter //AddKeys method adds keys to be deleted. AddKeys(keys ...string) }
type BatchDeleterRedis ¶
type BatchDeleterRedis struct {
// contains filtered or unexported fields
}
BatchDeleterRedis is a concrete implementation of the BatchDeleter interface based on Redis and RocksCache.
func NewBatchDeleterRedis ¶
func NewBatchDeleterRedis(redisClient redis.UniversalClient, options rockscache.Options) *BatchDeleterRedis
NewBatchDeleterRedis creates a new BatchDeleterRedis instance.
func (*BatchDeleterRedis) AddKeys ¶
func (c *BatchDeleterRedis) AddKeys(keys ...string)
AddKeys adds keys to be deleted.
func (*BatchDeleterRedis) ChainExecDel ¶
func (c *BatchDeleterRedis) ChainExecDel(ctx context.Context) error
ChainExecDel is used for chain calls for batch deletion. It must call Clone to prevent memory pollution.
func (*BatchDeleterRedis) Clone ¶
func (c *BatchDeleterRedis) Clone() BatchDeleter
Clone creates a copy of BatchDeleterRedis for chain calls to prevent memory pollution.
func (*BatchDeleterRedis) ExecDelWithKeys ¶
func (c *BatchDeleterRedis) ExecDelWithKeys(ctx context.Context, keys []string) error
ExecDelWithKeys directly takes keys for batch deletion and publishes deletion information.
type Option ¶
type Option func(c *RedisShardManagerConfig)
Option is a function type for configuring Config
func WithBatchSize ¶
WithBatchSize sets the number of keys to process per batch
func WithConcurrentLimit ¶
WithConcurrentLimit sets the concurrency limit
func WithContinueOnError ¶
WithContinueOnError sets whether to continue processing on error
type RedisShardManagerConfig ¶
type RedisShardManagerConfig struct {
// contains filtered or unexported fields
}
type ShardManager ¶
type ShardManager struct {
// contains filtered or unexported fields
}
ShardManager is a class for sharding and processing keys
func NewRedisShardManager ¶
func NewRedisShardManager(redisClient redis.UniversalClient, opts ...Option) *ShardManager
NewRedisShardManager creates a new RedisShardManager instance
func (*ShardManager) ProcessKeysBySlot ¶
func (rsm *ShardManager) ProcessKeysBySlot( ctx context.Context, keys []string, processFunc func(ctx context.Context, slot int64, keys []string) error, ) error
ProcessKeysBySlot groups keys by their Redis cluster hash slots and processes them using the provided function.