Documentation ¶
Index ¶
- type CacheRepo
- type IMessageCacheRepo
- type IUserCacheRepo
- type MessageRedisRepo
- type UserRedisRepo
- func (r *UserRedisRepo) DelAll()
- func (r *UserRedisRepo) FindRelevant(user *model.User, hobbies []model.Hobby, exceptUser []cachemodels.CachedUser, ...) ([]cachemodels.CachedUser, error)
- func (*UserRedisRepo) GenerateKey(sex bool, age int, username string, hobbies []model.Hobby) (strKey string)
- func (r *UserRedisRepo) GetAllUserByKey(key string) ([]cachemodels.CachedUser, error)
- func (r *UserRedisRepo) GetKeysMatch(sex bool, age int, hobbies []model.Hobby) ([]string, error)
- func (r *UserRedisRepo) Set(key string, cacheUser *cachemodels.CachedUser, expiration time.Duration) error
- func (r *UserRedisRepo) Sets(cachedUsers []cachemodels.CachedUser, expiration time.Duration)
- func (r *UserRedisRepo) UpdateExpiration(cUser *cachemodels.CachedUser, expiration time.Duration)
- func (r *UserRedisRepo) UpdateExpirationKey(key string, expiration time.Duration)
- func (r *UserRedisRepo) UpdateExpirations(cUsers []cachemodels.CachedUser, expiration time.Duration)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheRepo ¶
type CacheRepo struct { UserCacheRepo IUserCacheRepo MessageCacheRepo IMessageCacheRepo }
type IMessageCacheRepo ¶
type IUserCacheRepo ¶
type IUserCacheRepo interface { DelAll() Set(key string, cacheUser *cachemodels.CachedUser, expiration time.Duration) error GetAllUserByKey(key string) ([]cachemodels.CachedUser, error) Sets(cachedUsers []cachemodels.CachedUser, expiration time.Duration) GenerateKey(sex bool, age int, username string, hobbies []model.Hobby) (strKey string) FindRelevant(user *model.User, hobbies []model.Hobby, exceptUser []cachemodels.CachedUser, nUser int) ([]cachemodels.CachedUser, error) UpdateExpirations(cUsers []cachemodels.CachedUser, expiration time.Duration) UpdateExpiration(cUser *cachemodels.CachedUser, expiration time.Duration) UpdateExpirationKey(key string, expiration time.Duration) }
func NewUserRedisRepo ¶
func NewUserRedisRepo(client *redis.Client, conn *gorm.DB) IUserCacheRepo
type MessageRedisRepo ¶
type MessageRedisRepo struct {
// contains filtered or unexported fields
}
func NewMessageRedisRepo ¶
func NewMessageRedisRepo(client *redis.Client) *MessageRedisRepo
func (*MessageRedisRepo) Subscribe ¶
func (mrr *MessageRedisRepo) Subscribe(cvs *model.Conversation) (*redis.PubSub, error)
type UserRedisRepo ¶
type UserRedisRepo struct { Client *redis.Client CachedRepo databaserepo.ICachedRepo UserRepo databaserepo.IUserRepo HobbyRepo databaserepo.IHobbyRepo LikeAndDislikeRepo databaserepo.ILikeAndDislikeRepo }
func (*UserRedisRepo) DelAll ¶
func (r *UserRedisRepo) DelAll()
DelAll delete all the keys of all the existing databases, not just the currently selected one. This command never fails
func (*UserRedisRepo) FindRelevant ¶
func (r *UserRedisRepo) FindRelevant(user *model.User, hobbies []model.Hobby, exceptUser []cachemodels.CachedUser, nUser int) ([]cachemodels.CachedUser, error)
FindRelevant find nUser relevant
func (*UserRedisRepo) GenerateKey ¶
func (*UserRedisRepo) GenerateKey(sex bool, age int, username string, hobbies []model.Hobby) (strKey string)
GenerateKey create key follow format: 'sex:age:hobby...:username'
func (*UserRedisRepo) GetAllUserByKey ¶
func (r *UserRedisRepo) GetAllUserByKey(key string) ([]cachemodels.CachedUser, error)
GetAllUserByKey with key is key
func (*UserRedisRepo) GetKeysMatch ¶
GetKeysMatch create pattern key follow format: 'sex:age:hobby...*'
func (*UserRedisRepo) Set ¶
func (r *UserRedisRepo) Set(key string, cacheUser *cachemodels.CachedUser, expiration time.Duration) error
Set use SADD command to save data to set of redis
func (*UserRedisRepo) Sets ¶
func (r *UserRedisRepo) Sets(cachedUsers []cachemodels.CachedUser, expiration time.Duration)
Sets save to cache
func (*UserRedisRepo) UpdateExpiration ¶
func (r *UserRedisRepo) UpdateExpiration(cUser *cachemodels.CachedUser, expiration time.Duration)
func (*UserRedisRepo) UpdateExpirationKey ¶
func (r *UserRedisRepo) UpdateExpirationKey(key string, expiration time.Duration)
func (*UserRedisRepo) UpdateExpirations ¶
func (r *UserRedisRepo) UpdateExpirations(cUsers []cachemodels.CachedUser, expiration time.Duration)
Click to show internal directories.
Click to hide internal directories.