Documentation
¶
Index ¶
- type Cache
- func (c *Cache) Delete(ctx context.Context, request *DeleteRequest) (int64, error)
- func (c *Cache) Exists(ctx context.Context, request *ExistsRequest) (bool, error)
- func (c *Cache) Expire(ctx context.Context, request *ExpireRequest) (bool, error)
- func (c *Cache) Get(ctx context.Context, request *GetCacheRequest) (string, error)
- func (c *Cache) GetListIndex(ctx context.Context, request *GetListIndexRequest) (int, error)
- func (c *Cache) Inc(ctx context.Context, request *IncRequest) (int64, error)
- func (c *Cache) IncrBy(ctx context.Context, request *IncrByRequest) (int64, error)
- func (c *Cache) LPop(ctx context.Context, request *LPopRequest) (string, error)
- func (c *Cache) LPush(ctx context.Context, request *LPushRequest) (int64, error)
- func (c *Cache) LRange(ctx context.Context, request *LRangeRequest) ([]string, error)
- func (c *Cache) LRem(ctx context.Context, request *LRemRequest) (int64, error)
- func (c *Cache) LRemBeforeKey(ctx context.Context, request *LRemByValueRequest) error
- func (c *Cache) RPop(ctx context.Context, request *RPopRequest) (string, error)
- func (c *Cache) SAdd(ctx context.Context, request *SAddRequest) (int64, error)
- func (c *Cache) SCard(ctx context.Context, request *SCardRequest) (int64, error)
- func (c *Cache) Set(ctx context.Context, request *SetCacheRequest) error
- func (c *Cache) SetNX(ctx context.Context, request *SetNXRequest) (bool, error)
- func (c *Cache) TTL(ctx context.Context, request *TTLRequest) (time.Duration, error)
- func (c *Cache) ZAdd(ctx context.Context, request *ZAddRequest) (int64, error)
- func (c *Cache) ZCard(ctx context.Context, request *ZCardRequest) (int64, error)
- func (c *Cache) ZRange(ctx context.Context, request *ZRangeRequest) ([]string, error)
- func (c *Cache) ZRank(ctx context.Context, request *ZRankRequest) (int64, error)
- func (c *Cache) ZRem(ctx context.Context, request *ZRemRequest) (int64, error)
- func (c *Cache) ZScan(ctx context.Context, request *ZScanRequest) ([]string, uint64, error)
- type DeleteRequest
- type ExistsRequest
- type ExpireRequest
- type GetCacheRequest
- type GetListIndexRequest
- type IncRequest
- type IncrByRequest
- type LPopRequest
- type LPushRequest
- type LRangeRequest
- type LRemByValueRequest
- type LRemRequest
- type RPopRequest
- type SAddRequest
- type SCardRequest
- type SetCacheRequest
- type SetNXRequest
- type TTLRequest
- type ZAddRequest
- type ZCardRequest
- type ZRangeRequest
- type ZRankRequest
- type ZRemRequest
- type ZScanRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a struct that represents a Redis cache. It contains a prefix that is prepended to all keys in the cache, and a client that is used to interact with the Redis server.
func NewCache ¶
NewCache is a function that creates a new Cache. It takes a pointer to a redis.Options struct, which contains options for the Redis client, and a prefix string, which is prepended to all keys in the cache. It returns a pointer to the created Cache and an error.
func (*Cache) Delete ¶
Delete is a method of Cache that deletes a key from the cache. It takes a context and a pointer to a DeleteRequest struct, and returns the number of keys that were deleted as an int64 and an error. The method uses the Redis DEL command to delete the key.
func (*Cache) Exists ¶
Exists is a method of Cache that checks if a key exists in the cache. It takes a context and a pointer to an ExistsRequest struct, and returns a boolean indicating whether the key exists and an error. The method uses the Redis EXISTS command to check if the key exists.
func (*Cache) Expire ¶
Expire is a method of Cache that sets the expiration time of a key in the cache. It takes a context and a pointer to an ExpireRequest struct, and returns a boolean indicating whether the expiration time was set and an error. The method uses the Redis EXPIRE command to set the expiration time.
func (*Cache) Get ¶
Get is a method of Cache that gets a value from the cache. It takes a context and a pointer to a GetCacheRequest struct, and returns the value as a string and an error. The method uses the Redis GET command to get the value.
func (*Cache) GetListIndex ¶
GetListIndex is a method of Cache that gets the index of a value in a list in the cache. It takes a context and a pointer to a GetListIndexRequest struct, and returns the index of the value as an int and an error. The method uses the Redis LRANGE command to get the list, and then iterates over the list to find the value.
func (*Cache) Inc ¶
Inc is a method of Cache that increments a value in the cache. It takes a context and a pointer to an IncRequest struct, and returns the new value as an int64 and an error. The method uses the Redis INCR command to increment the value.
func (*Cache) IncrBy ¶
IncrBy is a method of Cache that increments a value in the cache by a certain amount. It takes a context and a pointer to an IncrByRequest struct, and returns the new value as an int64 and an error. The method uses the Redis INCRBY command to increment the value.
func (*Cache) LPop ¶
LPop is a method of Cache that pops a value from a list in the cache. It takes a context and a pointer to a LPopRequest struct, and returns the popped value as a string and an error. The method uses the Redis LPOP command to pop the value.
func (*Cache) LPush ¶
LPush is a method of Cache that pushes a value onto a list in the cache. It takes a context and a pointer to a LPushRequest struct, and returns the length of the list after the push as an int64 and an error. The method uses the Redis LPUSH command to push the value.
func (*Cache) LRange ¶ added in v0.0.19
LRange is a method of Cache that gets a range of values from a list in the cache. It takes a context and a pointer to a LRangeRequest struct, and returns the values as a slice of strings and an error. The method uses the Redis LRANGE command to get the values.
func (*Cache) LRem ¶ added in v0.0.21
LRem is a method of Cache that removes occurrences of a value from a list in the cache. It takes a context and a pointer to a LRemRequest struct, and returns the number of occurrences that were removed and an error. The method uses the Redis LREM command to remove the occurrences.
func (*Cache) LRemBeforeKey ¶ added in v0.0.27
func (c *Cache) LRemBeforeKey(ctx context.Context, request *LRemByValueRequest) error
LRemBeforeKey is a method of Cache that removes all elements in a list before a specified value. It takes a context and a pointer to a LRemByValueRequest struct, and returns an error if any occurs during the operation.
The method uses the Redis LRANGE command to get all elements in the list, then iterates over the list to find the specified value. If the value is found at the start of the list, all elements are removed using the Redis DEL command. If the value is found elsewhere in the list, all elements before it are removed using the Redis LTRIM command.
func (*Cache) RPop ¶
RPop is a method of Cache that pops a value from the end of a list in the cache. It takes a context and a pointer to a RPopRequest struct, and returns the popped value as a string and an error. The method uses the Redis RPOP command to pop the value.
func (*Cache) SAdd ¶ added in v0.0.16
SAdd is a method of Cache that adds members to a set in the cache. It takes a context and a pointer to a SAddRequest struct, and returns the number of members that were added and an error. The method uses the Redis SADD command to add the members.
func (*Cache) SCard ¶ added in v0.0.16
SCard is a method of Cache that gets the number of members in a set in the cache. It takes a context and a pointer to a SCardRequest struct, and returns the number of members as an int64 and an error. The method uses the Redis SCARD command to get the number of members.
func (*Cache) Set ¶
func (c *Cache) Set(ctx context.Context, request *SetCacheRequest) error
Set is a method of Cache that sets a value in the cache. It takes a context and a pointer to a SetCacheRequest struct, and returns an error. The method uses the Redis SET command to set the value.
func (*Cache) SetNX ¶ added in v0.0.21
SetNX is a method of Cache that sets a key in the cache, only if the key does not exist. It takes a context and a pointer to a SetNXRequest struct, and returns a boolean indicating whether the key was set and an error. The method uses the Redis SETNX command to set the key.
func (*Cache) TTL ¶
TTL is a method of Cache that gets the time to live of a key in the cache. It takes a context and a pointer to a TTLRequest struct, and returns the time to live as a time.Duration and an error. The method uses the Redis TTL command to get the time to live.
func (*Cache) ZAdd ¶
ZAdd is a method of Cache that adds members to a sorted set in the cache. It takes a context and a pointer to a ZAddRequest struct, and returns the number of members that were added and an error. The method uses the Redis ZADD command to add the members.
func (*Cache) ZCard ¶
ZCard is a method of Cache that gets the number of members in a sorted set in the cache. It takes a context and a pointer to a ZCardRequest struct, and returns the number of members as an int64 and an error. The method uses the Redis ZCARD command to get the number of members.
func (*Cache) ZRange ¶
ZRange is a method of Cache that gets a range of members from a sorted set in the cache. It takes a context and a pointer to a ZRangeRequest struct, and returns the members as a slice of strings and an error. The method uses the Redis ZRANGE command to get the members.
func (*Cache) ZRank ¶
ZRank is a method of Cache that gets the rank of a member in a sorted set in the cache. It takes a context and a pointer to a ZRankRequest struct, and returns the rank of the member as an int64 and an error. The method uses the Redis ZRANK command to get the rank.
func (*Cache) ZRem ¶
ZRem is a method of Cache that removes members from a sorted set in the cache. It takes a context and a pointer to a ZRemRequest struct, and returns the number of members that were removed and an error. The method uses the Redis ZREM command to remove the members.
func (*Cache) ZScan ¶
ZScan is a method of Cache that incrementally iterates over a sorted set in the cache. It takes a context and a pointer to a ZScanRequest struct, and returns the members as a slice of strings, the next cursor, and an error. The method uses the Redis ZSCAN command to iterate over the members.
type DeleteRequest ¶ added in v0.0.9
DeleteRequest is a struct that represents a request to delete a key from the cache. It contains the key to delete and an optional custom prefix.
type ExistsRequest ¶ added in v0.0.9
ExistsRequest is a struct that represents a request to check if a key exists in the cache. It contains the key and an optional custom prefix.
type ExpireRequest ¶ added in v0.0.9
ExpireRequest is a struct that represents a request to set the expiration time of a key in the cache. It contains the key, the expiration time in seconds, and an optional custom prefix.
type GetCacheRequest ¶ added in v0.0.9
GetCacheRequest is a struct that represents a request to get a value from the cache. It contains the key to get and an optional custom prefix.
type GetListIndexRequest ¶ added in v0.0.9
GetListIndexRequest is a struct that represents a request to get the index of a value in a list in the cache. It contains the key of the list, the value to find, and an optional custom prefix.
type IncRequest ¶ added in v0.0.9
IncRequest is a struct that represents a request to increment a value in the cache. It contains the key to increment and an optional custom prefix.
type IncrByRequest ¶ added in v0.0.9
IncrByRequest is a struct that represents a request to increment a value in the cache by a certain amount. It contains the key to increment, the amount to increment by, and an optional custom prefix.
type LPopRequest ¶ added in v0.0.9
LPopRequest is a struct that represents a request to pop a value from a list in the cache. It contains the key of the list and an optional custom prefix.
type LPushRequest ¶ added in v0.0.9
LPushRequest is a struct that represents a request to push a value onto a list in the cache. It contains the key of the list, the value to push, and an optional custom prefix.
type LRangeRequest ¶ added in v0.0.19
LRangeRequest is a struct that represents a request to get a range of values from a list in the cache. It contains the key of the list, the range to get, and an optional custom prefix.
type LRemByValueRequest ¶ added in v0.0.27
type LRemRequest ¶ added in v0.0.21
LRemRequest is a struct that represents a request to remove occurrences of a value from a list in the cache. It contains the key of the list, the count of occurrences to remove, the value to remove, and an optional custom prefix.
type RPopRequest ¶ added in v0.0.9
RPopRequest is a struct that represents a request to pop a value from the end of a list in the cache. It contains the key of the list and an optional custom prefix.
type SAddRequest ¶ added in v0.0.16
SAddRequest is a struct that represents a request to add members to a set in the cache. It contains the key of the set, the members to add, and an optional custom prefix.
type SCardRequest ¶ added in v0.0.16
SCardRequest is a struct that represents a request to get the number of members in a set in the cache. It contains the key of the set and an optional custom prefix.
type SetCacheRequest ¶ added in v0.0.9
SetCacheRequest is a struct that represents a request to set a value in the cache. It contains the key to set, the value to set it to, the expiration time in seconds, and an optional custom prefix.
type SetNXRequest ¶ added in v0.0.21
SetNXRequest is a struct that represents a request to set a key in the cache, only if the key does not exist. It contains the key, the value to set, the expiration time in seconds, and an optional custom prefix.
type TTLRequest ¶ added in v0.0.9
TTLRequest is a struct that represents a request to get the time to live of a key in the cache. It contains the key and an optional custom prefix.
type ZAddRequest ¶ added in v0.0.9
ZAddRequest is a struct that represents a request to add members to a sorted set in the cache. It contains the key of the sorted set, the members to add, and an optional custom prefix.
type ZCardRequest ¶ added in v0.0.9
ZCardRequest is a struct that represents a request to get the number of members in a sorted set in the cache. It contains the key of the sorted set and an optional custom prefix.
type ZRangeRequest ¶ added in v0.0.9
ZRangeRequest is a struct that represents a request to get a range of members from a sorted set in the cache. It contains the key of the sorted set, the start and end of the range, and an optional custom prefix.
type ZRankRequest ¶ added in v0.0.9
ZRankRequest is a struct that represents a request to get the rank of a member in a sorted set in the cache. It contains the key of the sorted set, the member to find, and an optional custom prefix.
type ZRemRequest ¶ added in v0.0.9
ZRemRequest is a struct that represents a request to remove members from a sorted set in the cache. It contains the key of the sorted set, the members to remove, and an optional custom prefix.
type ZScanRequest ¶ added in v0.0.9
ZScanRequest is a struct that represents a request to incrementally iterate over a sorted set in the cache. It contains the key of the sorted set, a cursor to resume the iteration, a match pattern to filter the members, a count to limit the number of returned members per call, and an optional custom prefix.