-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
57 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,59 @@ | ||
package redis | ||
|
||
import "github.com/go-redis/redis/v8" | ||
import ( | ||
"github.com/farseer-go/fs" | ||
"github.com/go-redis/redis/v8" | ||
) | ||
|
||
type redisSet struct { | ||
rdb *redis.Client | ||
} | ||
|
||
func (redisSet *redisSet) SetAdd(key string, members ...any) (bool, error) { | ||
result, err := redisSet.rdb.SAdd(ctx, key, members...).Result() | ||
result, err := redisSet.rdb.SAdd(fs.Context, key, members...).Result() | ||
return result > 0, err | ||
} | ||
|
||
func (redisSet *redisSet) SetCount(key string) (int64, error) { | ||
return redisSet.rdb.SCard(ctx, key).Result() | ||
return redisSet.rdb.SCard(fs.Context, key).Result() | ||
} | ||
|
||
func (redisSet *redisSet) SetRemove(key string, members ...any) (bool, error) { | ||
result, err := redisSet.rdb.SRem(ctx, key, members...).Result() | ||
result, err := redisSet.rdb.SRem(fs.Context, key, members...).Result() | ||
return result > 0, err | ||
} | ||
|
||
func (redisSet *redisSet) SetGet(key string) ([]string, error) { | ||
return redisSet.rdb.SMembers(ctx, key).Result() | ||
return redisSet.rdb.SMembers(fs.Context, key).Result() | ||
} | ||
|
||
func (redisSet *redisSet) SetIsMember(key string, member any) (bool, error) { | ||
return redisSet.rdb.SIsMember(ctx, key, member).Result() | ||
return redisSet.rdb.SIsMember(fs.Context, key, member).Result() | ||
} | ||
|
||
func (redisSet *redisSet) SetDiff(keys ...string) ([]string, error) { | ||
return redisSet.rdb.SDiff(ctx, keys...).Result() | ||
return redisSet.rdb.SDiff(fs.Context, keys...).Result() | ||
} | ||
|
||
func (redisSet *redisSet) SetDiffStore(destination string, keys ...string) (bool, error) { | ||
result, err := redisSet.rdb.SDiffStore(ctx, destination, keys...).Result() | ||
result, err := redisSet.rdb.SDiffStore(fs.Context, destination, keys...).Result() | ||
return result > 0, err | ||
} | ||
|
||
func (redisSet *redisSet) SetInter(keys ...string) ([]string, error) { | ||
return redisSet.rdb.SInter(ctx, keys...).Result() | ||
return redisSet.rdb.SInter(fs.Context, keys...).Result() | ||
} | ||
|
||
func (redisSet *redisSet) SetInterStore(destination string, keys ...string) (bool, error) { | ||
result, err := redisSet.rdb.SInterStore(ctx, destination, keys...).Result() | ||
result, err := redisSet.rdb.SInterStore(fs.Context, destination, keys...).Result() | ||
return result > 0, err | ||
} | ||
|
||
func (redisSet *redisSet) SetUnion(keys ...string) ([]string, error) { | ||
return redisSet.rdb.SUnion(ctx, keys...).Result() | ||
return redisSet.rdb.SUnion(fs.Context, keys...).Result() | ||
} | ||
|
||
func (redisSet *redisSet) SetUnionStore(destination string, keys ...string) (bool, error) { | ||
result, err := redisSet.rdb.SUnionStore(ctx, destination, keys...).Result() | ||
result, err := redisSet.rdb.SUnionStore(fs.Context, destination, keys...).Result() | ||
return result > 0, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters