redisv9

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RedisV9

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

func NewRedisV9WithConnection

func NewRedisV9WithConnection(conn model.Connector) (*RedisV9, error)

NewRedisV9WithConnection returns a new redisv8List instance with a custom redis connection.

func NewRedisV9WithOpts

func NewRedisV9WithOpts(options ...model.Option) (*RedisV9, error)

NewList returns a new RedisV9 instance.

func (*RedisV9) AddMember

func (r *RedisV9) AddMember(ctx context.Context, key, member string) error

Add the specified members to the set stored at key. Specified members that are already a member of this set are ignored. If key does not exist, a new set is created before adding the specified members. It errors if the key is not a set.

func (*RedisV9) AddScoredMember

func (r *RedisV9) AddScoredMember(ctx context.Context, key, member string, score float64) (int64, error)

AddScoredMember adds a member with a specific score to a sorted set in Redis. It returns the number of elements added to the sorted set, which is either 0 or 1.

func (*RedisV9) Append

func (r *RedisV9) Append(ctx context.Context, pipelined bool, key string, values ...[]byte) error

Insert all the specified values at the tail of the list stored at key. If key does not exist, it is created as empty list before performing the push operations. When key holds a value that is not a list, an error is returned. Equivalent to RPush.

func (*RedisV9) As

func (h *RedisV9) As(i interface{}) bool

As converts i to driver-specific types. redisv9 connector supports only *redis.UniversalClient. Same concept as https://gocloud.dev/concepts/as/ but for connectors.

func (*RedisV9) Decrement

func (r *RedisV9) Decrement(ctx context.Context, key string) (int64, error)

Decrement atomically decrements the integer value of a key by one

func (*RedisV9) Delete

func (r *RedisV9) Delete(ctx context.Context, key string) error

Delete removes the specified keys

func (*RedisV9) DeleteKeys

func (r *RedisV9) DeleteKeys(ctx context.Context, keys []string) (int64, error)

DeleteKeys removes the specified keys. A key is ignored if it does not exist

func (*RedisV9) DeleteScanMatch

func (r *RedisV9) DeleteScanMatch(ctx context.Context, pattern string) (int64, error)

DeleteScanMatch deletes all keys matching the given pattern

func (*RedisV9) Disconnect

func (h *RedisV9) Disconnect(ctx context.Context) error

func (*RedisV9) Exists

func (r *RedisV9) Exists(ctx context.Context, key string) (bool, error)

Exists checks if a key exists

func (*RedisV9) Expire

func (r *RedisV9) Expire(ctx context.Context, key string, expiration time.Duration) error

Expire sets a timeout on key. After the timeout has expired, the key will automatically be deleted

func (*RedisV9) FlushAll

func (r *RedisV9) FlushAll(ctx context.Context) error

func (*RedisV9) Get

func (r *RedisV9) Get(ctx context.Context, key string) (string, error)

Get retrieves the value for a given key from Redis

func (*RedisV9) GetKeysAndValuesWithFilter

func (r *RedisV9) GetKeysAndValuesWithFilter(ctx context.Context,
	pattern string,
) (map[string]interface{}, error)

GetKeysAndValuesWithFilter returns all keys and their values for a given pattern

func (*RedisV9) GetKeysWithOpts

func (r *RedisV9) GetKeysWithOpts(ctx context.Context,
	searchStr string,
	cursor map[string]uint64,
	count int64,
) ([]string, map[string]uint64, bool, error)

GetKeysWithOpts performs a paginated scan of keys in a Redis database using the SCAN command. It receives a cursor map that contains the cursor position for each Redis node in the cluster.

Parameters:

ctx:       Execution context.
searchStr: Pattern for filtering keys (glob-style patterns allowed).
cursor:    Map of Redis node addresses to cursor positions for pagination.
		   In the first iteration, map must be empty or nil.
count:     Approximate number of keys to return per scan.

Returns:

keys:          Slice of keys matching the searchStr pattern.
updatedCursor: Updated cursor map for subsequent pagination.
continueScan:  Indicates if more keys are available for scanning (true if any cursor is non-zero).
err:           Error, if any occurred during execution.

func (*RedisV9) GetMembersByScoreRange

func (r *RedisV9) GetMembersByScoreRange(ctx context.Context, key, min, max string) ([]interface{}, []float64, error)

GetMembersByScoreRange retrieves members and their scores from a Redis sorted set within the given score range specified by min and max. It returns slices of members and their scores, and an error if any occurs during retrieval.

func (*RedisV9) GetMulti

func (r *RedisV9) GetMulti(ctx context.Context, keys []string) ([]interface{}, error)

GetMulti returns the values of all specified keys

func (*RedisV9) Increment

func (r *RedisV9) Increment(ctx context.Context, key string) (int64, error)

Increment atomically increments the integer value of a key by one

func (*RedisV9) IsMember

func (r *RedisV9) IsMember(ctx context.Context, key, member string) (bool, error)

Returns if member is a member of the set stored at key.

func (*RedisV9) Keys

func (r *RedisV9) Keys(ctx context.Context, pattern string) ([]string, error)

Keys returns all keys matching the given pattern

func (*RedisV9) Length

func (r *RedisV9) Length(ctx context.Context, key string) (int64, error)

Returns the length of the list stored at key. If key does not exist, it is interpreted as an empty list and 0 is returned. An error is returned when the value stored at key is not a list. Equivalent of LLen.

func (*RedisV9) Members

func (r *RedisV9) Members(ctx context.Context, key string) ([]string, error)

Returns all the members of the set value stored at key

func (*RedisV9) Ping

func (h *RedisV9) Ping(ctx context.Context) error

func (*RedisV9) Pop

func (r *RedisV9) Pop(ctx context.Context, key string, stop int64) ([]string, error)

Pop removes and returns the first count elements of the list stored at key. If stop is -1, all the elements from start to the end of the list are removed and returned.

func (*RedisV9) Prepend

func (r *RedisV9) Prepend(ctx context.Context, pipelined bool, key string, values ...[]byte) error

Insert all the specified values at the head of the list stored at key. If key does not exist, it is created as empty list before performing the push operations. When key holds a value that is not a list, an error is returned. Equivalent to LPush.

func (*RedisV9) Publish

func (r *RedisV9) Publish(ctx context.Context, channel, message string) (int64, error)

Publish sends a message to the specified channel.

func (*RedisV9) Range

func (r *RedisV9) Range(ctx context.Context, key string, start, stop int64) ([]string, error)

Returns the specified elements of the list stored at key. The offsets start and stop are zero-based indexes, with 0 being the first element of the list (the head of the list), 1 being the next element and so on. Equivalent of LRange.

func (*RedisV9) Remove

func (r *RedisV9) Remove(ctx context.Context, key string, count int64, element interface{}) (int64, error)

Remove the first count occurrences of elements equal to element from the list stored at key. The count argument influences the operation in the following ways: count > 0: Remove elements equal to element moving from head to tail. count < 0: Remove elements equal to element moving from tail to head. count = 0: Remove all elements equal to element. Equivalent of LRem.

func (*RedisV9) RemoveMember

func (r *RedisV9) RemoveMember(ctx context.Context, key, member string) error

Remove the specified members from the set stored at key. Specified members that are not a member of this set are ignored. It errors if the key is not a set.

func (*RedisV9) RemoveMembersByScoreRange

func (r *RedisV9) RemoveMembersByScoreRange(ctx context.Context, key, min, max string) (int64, error)

RemoveMembersByScoreRange removes members from a Redis sorted set within a specified score range. It returns the number of members removed from the sorted set.

func (*RedisV9) Set

func (r *RedisV9) Set(ctx context.Context, key, value string, expiration time.Duration) error

Set sets the string value of a key

func (*RedisV9) SetIfNotExist added in v1.2.1

func (r *RedisV9) SetIfNotExist(ctx context.Context, key, value string, expiration time.Duration) (bool, error)

func (*RedisV9) Subscribe

func (r *RedisV9) Subscribe(ctx context.Context, channels ...string) model.Subscription

Subscribe initializes a subscription to one or more channels.

func (*RedisV9) TTL

func (r *RedisV9) TTL(ctx context.Context, key string) (int64, error)

TTL returns the remaining time to live of a key that has a timeout

func (*RedisV9) Type

func (h *RedisV9) Type() string

Jump to

Keyboard shortcuts

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